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 a spreadsheet (XLS) of names, email addresses, and passwords from another content management system. Is there a way to import these folks as users (I think subscriber level, but some may be Editors as well) into WordPress?

share|improve this question
add comment

3 Answers

up vote 6 down vote accepted

A new file, import.php:

<?php

define('WP_INSTALLING', true); // this is required. i forget why!

include '/path/to/wordpress/wp-load.php';
include ABSPATH . WPINC . '/registration.php'; // wp_insert_user()

$userdata = array('user_login' => 'jdoe', 'user_pass' => 'foobar');
$user_id = wp_insert_user($userdata);

Check wp_insert_user() for other possible fields. Run update_usermeta() for any additional needed meta fields. (Including user level, though there may be convenience functions.)

Note that here at work we redefine the wp_authenticate() function (it's in pluggable.php, so it can be replaced by defining it in your own plugin) and creating user accounts on-demand if they don't exist at login time.

share|improve this answer
    
I had not heard of wp_insert_user() - nice! –  artlung Aug 11 '10 at 20:55
    
Double-nice because you can use it on existing users (just pass $userdata['ID']). I recommend being familiar with both wp_insert_user() and wp_update_user(). –  Annika Backstrom Aug 12 '10 at 1:45
add comment

I would use a plugin for that. When done, remove the plugin.

This one by Dagon Design seems to do the trick, but it was not updated for wordpress 3. Don't know if it will work, so you migth want to try it on a sample wordpress.

share|improve this answer
add comment

You can also directly import them using the SQL databases, running an SQL query using the code from the downloaded SQL file from the previous server which contains all the users. That's what I would do, it is very easy.

share|improve this answer
1  
Using a SQL query, you wouldn't be able to import the passwords. WordPress doesn't use the MySQL PASSWORD() function, it uses PHPass. –  Matthew Boynes Aug 16 '12 at 18:51
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.