How to redirect users to their profile after they successfully edit their profile

I am using the buddypress plugin for wordpress and would like to make a little change…

I was wondering, if there was a way I could redirect users to their profile page after they save the edits to their profile page?

Read More

Basically, when a user edits their profile page it just shows a message that says something like “changes saved” but stays on the edit page.

I would like it to redirect to the user’s profile page so they can see the changes after they click the save changes button and it was successful.

I am thinking of using something like this:

function EditsSaved()
{
global $bp;
wp_redirect( $bp->loggedin_user->domain );
}
add_filter( 'SomethingHere', 'EditsSaved' );

I am a little unsure how to do this… what would I need to put in the ‘SomethingHere’ part that will fire when someone successfully saves the edits they make to their profile?

I have tried some code I found online but it did not work. I am using wordpress 3.8 and buddypress 1.9.1

Update:

Alright, I figured it out! It was just an issue off trying to use outdated code…

Here the function that works:

add_action( 'xprofile_updated_profile', 'SaveEditsRedirect', 12 );
function SaveEditsRedirect() {
global $bp;
wp_redirect( $bp->loggedin_user->domain );
exit;
}

Related posts