简体   繁体   English

更改用户密码! WordPress的

[英]Change User Password ! Wordpress

I wrote a wordpress template page to allow my users to change their password on FrontEnd. 我写了一个wordpress模板页面,以允许我的用户在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语句验证它们是否不同即可。 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 1:$ username
2: $pass 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
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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