简体   繁体   中英

Change User Password ! Wordpress

I wrote a wordpress template page to allow my users to change their password on FrontEnd.

On the form I check the current password and ask for the new password and a confirmation. Everything works fine for several changing passwords.

But when the new password is equal to a previous old password, it becomes impossible for the user to connect. I have to reset the password on the admin to restore access.

Anyone know why ?

Just validate they are not the same with an if statement. If the current password = new password then don't update the DB and return a message informing the user that they can't use the same password!

Please enter the username and password which is enter at that time.Here is the variable which you need to provide the value.
1: $username
2: $pass

$user = get_user_by( 'login', $username );

if ( $user && wp_check_password( $pass, $user->data->user_pass , $user->ID  ) )
{
message :Please use the another password
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM