The get_edit_profile_url() WordPress PHP function retrieves the URL to the user’s profile editor.
Usage
get_edit_profile_url($user_id, $scheme);
Parameters
$user_id
(int) – Optional. User ID. Defaults to the current user.$scheme
(string) – Optional. The scheme to use. Default is ‘admin’, which obeys force_ssl_admin() and is_ssl(). ‘http’ or ‘https’ can be passed to force those schemes. Default: ‘admin’.
More information
See WordPress Developer Resources: get_edit_profile_url()
Examples
Get the current user’s profile edit URL
This code retrieves the edit profile URL for the current user and echoes it in an anchor tag.
$current_user_id = get_current_user_id(); $profile_url = get_edit_profile_url($current_user_id); echo '<a href="' . esc_url($profile_url) . '">Edit Profile</a>';
Get a specific user’s profile edit URL
This code retrieves the edit profile URL for user with ID 5 and echoes it in an anchor tag.
$user_id = 5; $profile_url = get_edit_profile_url($user_id); echo '<a href="' . esc_url($profile_url) . '">Edit User 5 Profile</a>';
Force HTTPS scheme
This code retrieves the edit profile URL for the current user with HTTPS and echoes it in an anchor tag.
$current_user_id = get_current_user_id(); $profile_url = get_edit_profile_url($current_user_id, 'https'); echo '<a href="' . esc_url($profile_url) . '">Edit Profile (Secure)</a>';
Force HTTP scheme
This code retrieves the edit profile URL for the current user with HTTP and echoes it in an anchor tag.
$current_user_id = get_current_user_id(); $profile_url = get_edit_profile_url($current_user_id, 'http'); echo '<a href="' . esc_url($profile_url) . '">Edit Profile (Insecure)</a>';
Get edit profile URL for all users
This code retrieves the edit profile URL for all users and echoes them in a list.
$users = get_users(); foreach ($users as $user) { $user_id = $user->ID; $profile_url = get_edit_profile_url($user_id); echo '<li><a href="' . esc_url($profile_url) . '">Edit Profile for ' . esc_html($user->display_name) . '</a></li>'; }