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.

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

share|improve this question
    
give me a help......... –  wordpresrox Jul 16 '13 at 8:32
add comment

2 Answers

up vote 2 down vote accepted

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 )
   );
}
share|improve this answer
    
thanks......... –  wordpresrox Jul 16 '13 at 10:01
add comment

Well for creating hash passwords have a look at this:

http://codex.wordpress.org/Function_Reference/wp_hash_password

IT sounds like it's not hashing it properly. for example:

$password_hashed = '$P$B55D6LjfHDkINU5wF.v2BuuzO0/XPk/';
$plain_password = 'test';

That utilises MD5.

Try reading into wp_hash_password

share|improve this answer
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.