I am building a external application for which user login credentials will be taken from WordPress site database table ‘users’
WordPress uses PHPass hashing , I am unable to validate username and password for my external application as the password in database table 'users'
is hashed
I am trying to check plain password with hashed password using wp_check_password
function but I am failing, nothing is written back with this code
<?php
$password = '965521425';
$hash = '$P$9jWFhEPMfI.KPByiNO9IyUzSTG7EZK0';
require_once('/home/nhtsoft/public_html/project/wp-includes/class-phpass.php');
function wp_check_password($password, $hash) {
global $wp_hasher;
if ( empty($wp_hasher) ) {
$wp_hasher = new PasswordHash(8, true);
}
$check = $wp_hasher->CheckPassword($password, $hash);
return apply_filters('check_password', $check, $password, $hash);
}
?>
this code is giving me an empty page.
How to check this password so that I can use these WordPress credentials for external app login?
you have passed wrong hash value , hash value for 965521425 is $P$BmI5G.LOoEx1iH.naNqVhWnSh5sMp31 and you just need to write below code into your file:
In your code, you include the wp library and it looks like you redefine a function named
wp_check_password
but you do not call any function at all. Add the following line before the closing php tag (“?>”) and try again.Keep an eye on the error logs in case you miss some dependencies.
i would simply do this
<?php wp_check_password( $password, $hash, $user_id ) ?>
ReferTry this…
I work’s fine for me
what Bhumi Shah wrote is correct you should add
to your code .
but hashed value for any password(number or text) is not one solid thing , it could be many things that’s why they can be compared only with wp_check_password