Retrieves a user row based on password reset key and login
A key is considered 'expired' if it exactly matches the value of the user_activation_key field, rather than being matched after going through the hashing process. This field is now hashed; old values are no longer accepted but have a different WP_Error code so good user feedback can be provided.
WP_User|WP_Error. WP_User object on success, WP_Error object for invalid or expired keys.
Usage
check_password_reset_key( $key, $login );
$key(string) (required)
Hash to validate sending user's password.
$login(string) (required)
The user login.
Examples
0
#1 Example of creating and verifying a key to restore a pasword
// create a key for user 1 with the username siesta
$user = get_userdata( 1 );
$key = get_password_reset_key( $user ); // ZedUm9FEt48Kp4aGb5i8
// check the created key
$ok = check_password_reset_key( $key, 'siesta' );
if( is_wp_error( $ok ) ){
echo $ok->get_error_message();
}
else {
echo 'The key has been verified. You can send a new password to the email.';
}
Notes
Global. wpdb. $wpdb WordPress database object for queries.