[insert_php]
$err = ”;
$success = ”;
$current_user = wp_get_current_user();
global $wpdb;
if(isset($_POST[‘task’]) && $_POST[‘task’] == ‘update’ ) {
$email = $current_user->user_email;
$password = $wpdb->escape(trim($_POST[‘password’]));
$cpassword = $wpdb->escape(trim($_POST[‘cpassword’]));
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;
wp_set_password( $password, $user_id );
$success = ‘Password Changed Successfully’;
}
}
[/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]