Hook *after* user password change?

I know that password_reset hooks:

Runs after the user submits a new password during password reset 
but before the new password is actually set. 

but there is a similar hook AFTER the new password is actually set?

EDIT: It would be logical to use profile_update but I tried, and profile_update seems not get called in case of password change for a ‘lost password’ procedure, for example.
My real problem is auto login after password reset, and the only solution found till now, was using password_reset hook calling manually a wp_set_password before executing my code, so to be sure that password gets changed and THEN my code gets executed. This is not a clean procedure, and I am wondering if there is a solution that is less ‘hacky’… I searched a lot, looking at every action hook in wordpress doc, but i can’t find a proper solution.

2 s
2

I wonder if you’re looking for this one:

 /**
  * Fires after the user's password is reset.
  *
  * @since 4.4.0
  *
  * @param object $user     The user.
  * @param string $new_pass New user password.
  */
  do_action( 'after_password_reset', $user, $new_pass );

It was introduced in WordPress 4.4 and lives within the reset_password() function. The after_password_reset hook fires after the wp_set_password().

Update

Here’s an untested pre 4.4 workaround idea:

/**
 * Support for the 'after_password_reset' hook in WordPress pre 4.4
 */
add_action( 'password_reset', function( $user, $new_pass )
{
    add_filter( 'pre_option_admin_email', 
        function( $pre_option, $option ) use ( $user, $new_pass )
        {
            // Setup our 'after_password_reset' hook
            if( ! did_action(  'after_password_reset' ) )
                do_action( 'after_password_reset', $user, $new_pass );

            return $pre_option;  
        }  10, 2 );    
}, 10, 2 );

where you should now have your own custom after_password_reset hook.

Remember to backup database before testing.

Leave a Comment