Our current system (not using Wordpress) has 1000 users that we need to transfer to Wordpress. The problem we are facing is that passwords cannot remain the same.
In our current system, passwords are saved using:
md5( md5( $password ) . USER_SALT );
Not the best, but not the worst ...
We need to make these password hashes that we are currently working in WP. Is there a way to start all new passwords using this setting, and then through WP's own hashing?
I know that you can connect to the following functions:
function my_hash_password($password){ return md5( md5( $password ) . USER_SALT ); } add_action('wp_hash_password', 'my_hash_password' );
For some reason this does not fully work.
Of course, someone else has already gone through this before.
Thanks.
CHANGE !!!!
There is still some confusion. I DO NOT ask not to hashed the hashed password that we have. I say that with our current system, passwords look like this:
Password: password Hash function: md5( md5( $password ) . USER_SALT ); Output: d372f9c033e9c358b111ff265e080d3a
I want to "possibly" be able to take the hash above and pass it to my own WP WP hash, so that:
d372f9c033e9c358b111ff265e080d3a
becomes ...
$P$BdrwxndTzgTVHUozGpQ9TEMYd6mpTw0
after he fulfills his function.
Then, when the user logs in, we send our plain text password back through our function, and then through WP to get the match.
////////////////////////
UPDATE !!!
///////////////////////
Trying to override the wp_check_password function that connects to WP, but for some reason it does not work.
function my_check_password($password, $hash, $user_id = '') { global $wp_hasher; if ( $hash == md5( md5( $password ) . USER_SALT ) ){ if ( $user_id ) { $check = true; wp_set_password($password, $user_id); $hash = wp_hash_password($password); } return apply_filters( 'check_password', $check, $password, $hash, $user_id ); } // If the hash is still md5... elseif ( strlen($hash) <= 32 ) { $check = hash_equals( $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 . WPINC . '/class-phpass.php'); // By default, use the portable hash from phpass $wp_hasher = new PasswordHash(8, true); } $check = $wp_hasher->CheckPassword($password, $hash); /** This filter is documented in wp-includes/pluggable.php */ return apply_filters( 'check_password', $check, $password, $hash, $user_id ); } add_action('wp_check_password', 'my_check_password' );
Does anyone have any ideas?