0

Is there any way to redirect /wp-admin/profile.php to /members/your-profile

I do not want members to go to the default wp-admin page but instead go to the custom members page.

I tried a redirect via a redirection app, but that didn't work.

Thanks!

1 Answer 1

0

You might be able to use the edit_profile_url filter:

add_filter( 'edit_profile_url, 'wpse419568_user_profile_redirect', 10, 3 );
/**
 * Filters the URL for the user profile.
 *
 * @param  string $url     The profile URL.
 * @param  int    $user_id The user ID.
 * @param  string $scheme  The URL scheme (eg http, https, login, etc.).
 * @return string          The filtered URL.
 */
function wpse419568_user_profile_redirect( $url, $user_id, $scheme ) {
    // Don't change the URL for admin users.
    if ( ! current_user_can( 'manage_options' ) ) {
        // Assumes that the profile URL uses the User ID. Adjust to suit
        // your site's use case.
        $url = '/members/profile/' . absint( $user_id ); 
    }
    return $url;
}

Note: This code is untested and comes with no guarantee it will work. It's meant as a starting point, not a finished solution. Test it on a disposable / test site first.

1
  • Thanks, Appreciate the response. I have tried the code, but sadly couldn't get it to work. So must be doing something wrong
    – Ian
    Dec 11, 2023 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.