[insert_php]
$err = ”;
$success = ”;
global $wpdb;
if(isset($_POST[‘task’]) && $_POST[‘task’] == ‘update’ ) {
$email = $_GET[’email’];
$validity = $_GET[‘validity’];
$password = $wpdb->escape(trim($_POST[‘password’]));
$cpassword = $wpdb->escape(trim($_POST[‘cpassword’]));
if(!$email) {
$err = ‘Invalid email!’;
}
else if(!$validity){
$err = ‘Invalid validity token!’;
}
else if($password == “”) {
$err = ‘Password Cant be empty!’;
} else if($password!=$cpassword) {
$err = ‘Password not match’;
} else {
$user = get_user_by( ’email’, $email );
$user_id = $user->id;
$is_requested = get_user_meta ($user_id, ‘validity’, true);
if ($is_requested == $validity){
wp_set_password( $password, $user_id );
$success = ‘Password Changed Successfully’;
}
else{
$err = “Invalid validity token”;
}
}
}
[/insert_php]
PASSWORD RESET FORM
[insert_php] if(! empty($err) ) : echo ”.’
‘.$err.’
‘.”; endif; [/insert_php]
[insert_php] if(! empty($success) ) : echo ”.’
‘.$success.’
‘.”; endif; get_header();
[/insert_php]