Match user password in wordpress

0.58K views
no comments
25 Oct 2014 1:22 pm

The wordpress user’s password hashing is very strong you cannot manually match the entered password with stored in db password because every single time wordpress generate password with random characters, so here is a function to match the wordpress user login password for login functionality or change password functionality in your website…

function check_wp_pass($check_pass, $user_id) {
    $user = get_userdata( $user_id );
    //GET USER INFORMATION

    $user_db_pass = $user->data->user_pass;
    //GET USER'S STORED PASSWORD

    require_once( ABSPATH . 'wp-includes/class-phpass.php');
    //IN 3.6 OR OLRDER VERSION CANNOT AUTO LOAD PASSWORD CLASS SO YOU WILL NEED TO LOAD IT MANNUALLY

    $wp_hasher = new PasswordHash(8, TRUE);

    if($wp_hasher->CheckPassword($check_pass, $user_db_pass)) {
        return true;
        //HERE PASSWORD MATCHED
    } else {
        return false;
        //HERE PASSWORD NOT MATCHED
    }
}

NOTE:Your Email Address will be not shown and please do not add spamming comments because here is REL="NOFOLLOW" on your links and comments also moderated shown.
<code>Put html css or any language code under this tag</code>