Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_check_password [ WordPress Function ]

wp_check_password ( $password, $hash, $user_id = '' )
Parameters:
  • (string) $password Plaintext user's password
  • (string) $hash Hash of the user's password to check against.
Uses:
  • PasswordHash::CheckPassword
Returns:
  • (bool) False, if the $password does not match the hashed password
Defined at:



Checks the plaintext password against the encrypted Password.

Maintains compatibility between old version and the new cookie authentication protocol using PHPass library. The $hash parameter is the encrypted password and the function compares the plain text password when encrypted similarly against the already encrypted password to see if they match.

For integration with other applications, this function can be overwritten to instead use the other package password checking algorithm.

Source


<?php
function wp_check_password($password$hash$user_id '') {
    global 
$wp_hasher;

    
// If the hash is still md5...
    
if ( strlen($hash) <= 32 ) {
        
$check = ( $hash == md5($password) );
        if ( 
$check && $user_id ) {
            
// Rehash using new hash.
            
wp_set_password($password$user_id);
            
$hash wp_hash_password($password);
        }

        return 
apply_filters('check_password'$check$password$hash$user_id);
    }

    
// If the stored hash is longer than an MD5, presume the
    // new style phpass portable hash.
    
if ( empty($wp_hasher) ) {
        require_once( 
ABSPATH 'wp-includes/class-phpass.php');
        
// By default, use the portable hash from phpass
        
$wp_hasher = new PasswordHash(8true);
    }

    
$check $wp_hasher->CheckPassword($password$hash);

    return 
apply_filters('check_password'$check$password$hash$user_id);
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics