Importing Existing Users with Passwords

I have an existing legacy PHP site of 15000 users with base64 hashed passwords , I would like to import all these users into the new wordpress site with their passwords , What would be the best approach to realize this?

Praveen

Related posts

3 comments

  1. You can use wp_insert_user. Since your old database has passwords in base64, you can easily get the original password string using base64_decode.

    $new_user_data = array(
            'user_pass' => 'password',//pass your decoded password string
            'user_login' => 'username',//pass your username
            'user_email' => 'email',
            'first_name' => 'firstname',
            'last_name' => 'lastname',
            'role' => 'author'//if you want to specify a different role other than default one
    );
    wp_insert_user( $new_user_data );
    

    You need to format your old data in csv or xml or text file and read and pass them accordingly. And don’t try to import all 15000 users at once. Do this in several parts. Also sleep() function will be quiet good to give the server some rest.

  2. WordPress uses MD5 for encrypting the passwords. So I don’t think direct import of users will work here. You can either write script to import users with new auto generated passwords and fire emails to all.

    OR

    Use the 'authenticate', 'wp_authenticate_user' filter hooks to validate users with the existing table of users. http://codex.wordpress.org/Plugin_API/Filter_Reference/authenticate

    This plugin might help: http://wordpress.org/plugins/external-database-authentication/

  3. WP using md5 for encryption and you have base64 so I don’t think that you can directly import the same password.
    But as we all know that base64 can be decode http://www.php.net/base64_decode so it is clear that we can import your old password as well
    But there is several WP plugin which will import users from CSV file to WP database and with new password. And system will send new credential notification mail to that user as well. http://wordpress.org/plugins/members-import/ this plugin can help you to do the same.
    In this plugin where password field data from CSV file is used pass that string to base64_decode() function.

    If you are importing same password then no need to send notification mail.

Comments are closed.