一. wp_users表
检测和更新操作
$user_name = $data['user_name'];
$user_pass = $data['old_passwd'];
// wp 判断 user表里是否有这个登陆名
$user = get_user_by( 'login',$user_name );
//检测密码和修改数据 以user表的ID为原点
// wp内置方法 只能检查 wp_users表
if ($user && wp_check_password($user_pass, $user->data->user_pass, $user->ID)) {
$user_data = wp_update_user( array( 'ID' => $user->ID, 'user_pass' => $data['new_passwd'] ) );
// 这里修改密码
if ( is_wp_error( $user_data ) ) {
// There was an error; possibly this user doesn't exist.
$res = array('code' => 1, 'message' => '修改密码失败', 'data' => null);
} else {
// Success!
$res = array('code' => 0, 'message' => '修改成功', 'data' => null);
}
} else {
$res = array('code' => 1, 'message' => '用户密码错误', 'data' => null);
}