The edit_profile_url WordPress PHP filter allows you to modify the URL for a user’s profile editor.
Usage
add_filter('edit_profile_url', 'your_custom_function', 10, 3); function your_custom_function($url, $user_id, $scheme) { // your custom code here return $url; }
Parameters
- $url (string): The complete URL including scheme and path.
- $user_id (int): The user ID.
- $scheme (string): Scheme to give the URL context. Accepts ‘http’, ‘https’, ‘login’, ‘login_post’, ‘admin’, ‘relative’ or null.
More information
See WordPress Developer Resources: edit_profile_url
Examples
Change the profile editor URL
Modify the profile editor URL to a custom page.
add_filter('edit_profile_url', 'change_profile_editor_url', 10, 3); function change_profile_editor_url($url, $user_id, $scheme) { $new_url = home_url('/custom-profile-editor/'); return $new_url; }
Add a query parameter
Add a custom query parameter to the profile editor URL.
add_filter('edit_profile_url', 'add_query_parameter', 10, 3); function add_query_parameter($url, $user_id, $scheme) { $url = add_query_arg('your_parameter', 'value', $url); return $url; }
Force HTTPS for profile editor URL
Ensure the profile editor URL uses HTTPS.
add_filter('edit_profile_url', 'force_https_profile_editor', 10, 3); function force_https_profile_editor($url, $user_id, $scheme) { $url = set_url_scheme($url, 'https'); return $url; }
Redirect to a third-party profile editor
Redirect users to a third-party profile editor, based on user role.
add_filter('edit_profile_url', 'redirect_third_party_editor', 10, 3); function redirect_third_party_editor($url, $user_id, $scheme) { $user = get_userdata($user_id); if (in_array('subscriber', $user->roles)) { $url = 'https://third-party-profile-editor.com/user/' . $user_id; } return $url; }
Add an anchor to the profile editor URL
Add an anchor to the profile editor URL, for example to focus on a specific section of the page.
add_filter('edit_profile_url', 'add_url_anchor', 10, 3); function add_url_anchor($url, $user_id, $scheme) { $url .= '#your-anchor'; return $url; }