Import users with pre-hashed passwords to WordPress

Pedro Gomes
1 min readJan 4, 2015

--

A while ago I was migrating a 10 year old CMS to WordPress and during the migrationg I was faced with the question about how to preserve a 1000 user database. Looking around for WordPress plugins only revealed solutions that take in plain text passwords but the CMS was using md5 hashing.

For that reason, I started looking at the WordPress Core code and came up with the following solution:

  1. Install this plugin: Import users from csv with meta

2. Temporarily edit wp-includes/user.php line 1716 and replace this:

$user_pass = wp_hash_password( $userdata[‘user_pass’] );

with

$user_pass = $userdata[‘user_pass’];

Run the plugin to import users to the database, and revert the changes on wp-includes/user.php once done otherwise users won’t be able to login.

Solution might fail in the future as WordPress can migrate to stronger hashing algorithms than md5.

--

--