Created
July 7, 2016 16:05
-
-
Save alokstha1/0251b0db193227c241707938f2f35340 to your computer and use it in GitHub Desktop.
Change password frontend WP function
This file contains hidden or 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
function change_pass_frontend() { | |
require_once( ABSPATH . 'wp-includes/class-phpass.php'); | |
$old_pass = $_POST['old_pass']; | |
$new_pass = $_POST['new_pass']; | |
$user_id = $_POST['user_id']; | |
$user_data = get_userdata( $user_id ); | |
$wp_hasher = new PasswordHash(8, TRUE); | |
$password_hashed = $user_data->user_pass; | |
if($wp_hasher->CheckPassword($old_pass, $password_hashed)) { | |
wp_set_password( $new_pass, $user_id ); | |
die('Your password is changed succssfully'); | |
} else { | |
die('Your old password did not match'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment