Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When I run wp_hash_password("password") twice the outputs are different. I was under the impression that this is not how hashes are supposed to work. So how should I use wp_hash_password to compare two hashes?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

That's just not the way it works. wp_hash_password() will always return a different value for the same password due to SALTing.

You are searching for the wp_check_password() function.

share|improve this answer
    
Of course, stupid of me, thannks –  Joren Oct 11 '13 at 13:52
    
@Joren Happy to help. :-) Feel free to accept it, if the answer helped you. –  s1lv3r Oct 11 '13 at 14:46
add comment

You can use wp_check_password() , see http://codex.wordpress.org/Function_Reference/wp_check_password

global $current_user;
get_currentuserinfo();
$user = $current_user;
    if ( wp_check_password( $_POST['current_password'], $user->user_pass, $user->ID) )//check password
   {
             //go ahead and change the password of stuff
             //....
   }
share|improve this answer
1  
Please add a short explanation to your answer. –  Pieter Goosen 2 days ago
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.