Wordpress Reset Password of login user

Reset password of a login user. While resetting a login user password remember you must use the function

See the below example:

     global $userdata;

     if (isset($_POST['submit_resetpass'])) {
         $error = "";
         $success = "";
         $new_password = trim($_POST['new_password']);
         $retype_password = trim($_POST['retype_new_password']);
         $current_user_id = $userdata->ID;
         if( $new_password == $retype_password ){
           wp_set_password($new_password, $current_user_id);
           $success = "Password successfully reset.";
           $error = "Password not matched, please try again.";

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s