1

I have been working around with adding stuff in user profile edit area. I am done with that but there is one thing I am unable to sort out.

What I am planning to do is to redirect a user to a custom page (custom member page) after they successfully edited their profile (wp-admin/profile.php) . In case of error they stay there. Help is appreciate :) Thanks

  • I am also looking for the same and in addition to that I want to have two more things 1. I want to redirect users to the same profile page with a message saying "profile updated" when they change their email id 2. Redirect users to the login page after changing their password because changing password logs them out. Could you guys help me out? – Akbar Basha Oct 23 '20 at 7:37
  • @AkbarBasha this isn't a discussion forum, don't post replies as answers/solutions, if you have a new question ask it as a new question – Tom J Nowell Oct 23 '20 at 10:56
2

This is the function that you need:

add_action( 'profile_update', 'custom_profile_redirect', 12 );
function custom_profile_redirect() {
    if(is_admin()):
        wp_redirect( trailingslashit( home_url() ) );
        exit;
    endif;
}

Just change the target of wp_redirect to whatever URL you want your users to go to. You can even add conditional logic to it if you only want this to happen for certain users, like the function below:

add_action( 'profile_update', 'custom_profile_redirect', 12 );
function custom_profile_redirect() {
    if ( is_admin() && current_user_can( 'subscriber' ) ) {
        wp_redirect( trailingslashit( home_url() ) );
        exit;
    }
}

Hope this helps! You can learn more about it from this tutorial I wrote.

  • Hi Thomas, I know how to add a textbox profile field but how can I add a textarea on profile.php ? Should I create a new question for you ? – EnexoOnoma Jun 28 '11 at 14:09
0
add_action('personal_options_update', 'redirect_me');
function redirect_me(){
  wp_redirect(home_url('/'));
  exit;
}
  • Hey, thx,, yes it is redirecting but it isn't saving or updating the changes . – Ayaz Malik Jan 14 '11 at 1:55
  • I don't see any other hook there, so I guess the only way is to edit the .php file... – onetrickpony Jan 14 '11 at 2:30
  • oh hmm k . thx :) – Ayaz Malik Jan 14 '11 at 3:11
0

this is old but i'll add to this as i was looking for a similar solution and this was the closest result.

personal_options_update fires before updating the profile

profile_update fires after the updating the profile

add_action('profile_update', 'redirect_me');
function redirect_me(){
  wp_redirect(home_url('/'));
  exit;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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