Hook *after* user password change?

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