I have set of user data from another wordpress site and i want o create users for each of them in a another wordpress web site..,it is works fine with wp_insert_user($user)
but problem is the password is hashed agin..,so i can’t log with that login information,so how can i create user with hash password or stop creating hashed password
2 Answers
You would have to update the password column in the database (see below). But this alone won’t work. Password hashes are salted using the SALT keys in your wp-config.php
(this must be kept secret). Your new site would need to have identical keys for the password verification to work.
The following function updates a given user’s password field (in the database) with the provided (hashed) password:
/**
* @param int $user_id The user ID
* @param string $hashed_password The hashed password
* @return int The number of rows updated (should be 1 or 0 ).
*/
function wpse_update_password_field( $user_id, $hashed_password ){
global $wpdb;
return $wpdb->update(
$wpdb->users,
array( 'user_pass' => $hashed_password ),
array( 'ID' => $user_id )
);
}