-
-
Save maplerock/8aca49a855899e82fc43bb5def586cab to your computer and use it in GitHub Desktop.
Huh π€·π»ββοΈ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include './wp-load.php'; | |
$username = $_REQUEST['username']; | |
$user = get_user_by('login',$username); | |
$userId = $user->data->ID; | |
$password = $_REQUEST['password']; | |
$new_password = $_REQUEST['new_password']; | |
if(empty($username)){ | |
$json = array('status'=>false,'msg'=>'Please enter user name'); | |
echo json_encode($json); | |
exit; | |
} | |
if(empty($password)){ | |
$json = array('status'=>false,'msg'=>'Please enter old password'); | |
echo json_encode($json); | |
exit; | |
} | |
if(empty($new_password)){ | |
$json = array('status'=>false,'msg'=>'Please enter new password'); | |
echo json_encode($json); | |
exit; | |
} | |
$hash = $user->data->user_pass; | |
$code = 500; $status = false; | |
if (wp_check_password( $password, $hash ) ){ | |
$msg = 'Password updated successfully'; | |
$code = 200; $status = true; | |
wp_set_password($new_password , $userId); | |
}else{ | |
$msg = 'Current password does not match.'; | |
} | |
$json = array('code'=>$code,'status'=>$status,'msg'=>$msg); | |
echo json_encode($json); | |
exit; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment