WordPress Mass Account Import

While working on a couple of WordPress projects for two sites I host (www.cambridgerepeaters.net & www.cambridgeshire-raynet.net) I had the need to do mass account creation.  These were 30+ accounts at a time, not a thrilling prospect to do that via the normal admin interface.  Searching the net was nearly useless, until I found a WP plugin called “Import Users Plugin for WordPress”.  This worked, but was very simple and didn’t suit my needs.

So, after looking at the script and figuring out how it worked (I’m not PHP coder but I can get by in a pinch), I managed to hack the script to do what I wanted.  The script as provided above only allows for the email address and login name, the 2 required bits of info to create a new account on a WP system.  However, I needed to be able to specify:

  • first name
  • last name
  • password

Another nice thing to have on the import is being able to set the WordPress user role (access level), so I shoved that in as well.  On the plugin page I posted a comment about my updates and a link to the new modified script:

I’d like to submit another modified version of this great script. The changes I’ve made to the script allows for adding first and last names, setting a password and setting the role for the imports. I’m also using the more powerful method of account creation, “wp_insert_user” this allows a lot more in the way of adding nice things to the script and new account.

The import file or manually entered format is:

username|firstname|lastname|password|email|role

All fields except username and email are optional, but all fields must be delimited, ie:

fred|Fred|Rivers|mypassw0rd|fred@rivers.com|Editor
sam|Sam||sam@mypress.com|

Fred has everything assigned while Sam will be emailed his generated password and his role will be set to whatever was selected from the drop down box on the form.

I’d be interested in any comments on my changes. There have been quite a few changes, I suggest a diff of mine and the latest modified one.

My modified version can be found at:

http://www.uk-experience.com/scripts/dd-import-users-mod_wp27.txt

I hope people find this useful, I think it’s a function that’s needed by far more people then you might expect.  In my mind, it’s something that should be part of the core code for WordPress.  I can see more modifications coming to this script as my projects progress.  While looking into changes for the script I’ve found other things that would be nice to have at the time of import too…

Watch this space…
Updated script

2009.06.17 @ 2013GMT

Version 1.1.13 – Added user URL to be imported into user details (not the default assigned blog for WPMU)

dd-import-users-mod_wp27_v1.1.13.txt

Note the new format when using this version:

The import file or manually entered format is:

username|firstname|lastname|password|email|role|URL

All fields except username and email are optional, but all fields must be delimited, ie:

fred|Fred|Rivers|mypassw0rd|fred@rivers.com|Editor|http://blah.com
sam|Sam||sam@mypress.com||


46 Responses to WordPress Mass Account Import

  1. I imported 500(subscribed) users from my old site and have had 55(registered subscribers) new users sign up but i want them all to be subscribed is there a plugin for this after the users are in?

    If i got into Tools>>Subscribers i can see that all the ones i imported are not subscribed. I can manually edit each one to Automatically subscribe me to newly created categories:. Can a plugin do all these to same tones of time?

    • Avatar kelly
      kelly says:

      Daniel,
      Did you assign the role? If you matched the text string for the subscribed person in your new blog, it should have worked. If you left it blank, then the script couldn’t assign them as a subscriber. Also make sure you are using the latest version of the script. there are three updates listsed above.. you want the most recent one. The early version didn’t assign role.

      username|firstname|lastname|password|email|role|URL

      • Hi, sorry to say it wasn’t your plugin. I should have mentioned that. Mainly my question was related to how i could adjust where it’s currently at! If i try to do this from now what would you suggest?

  2. Am i crazy or is this code behind a log in? I tried to follow the links, but hit a log in for grammary-tech.com and my google log in did not get me past.

    • Sorry about that, a recent change in my server configuration caused that problem. I’ve corrected the links now. Thanks for letting me know about that.

  3. Works great, thanks!

    My only wish is for it not to email the new user.

    I tried the “Allow Multiple Accounts” plugin which is supposed to ‘Allow multiple user accounts to be created from the same email address’, but that didn’t work with this plugin, which still requires a unique email address.

    My only option seems to be to put in fake email addresses.

    Any other suggestions?

    BTW, I’m a little confused how the ‘role’ field works…if I assign the role to each user per line do I also need to select that role from the drop-down?

  4. Hi Kenn,

    Sorry, I can’t help at all with your problem. Perhaps someone else can that’s reading my site, failing that go to the original authors site and post your quesiton in their comments to see if anyone can lend a hand.

    Sadly, my only real language is English 🙂

  5. The script fails when I’m trying to import records which contains danish characters like æ,ø and å. Any chance to fix this would be great 🙂

    – Kenn

  6. Awesome. I’ve been looking for something like this for a bit. In my case, I’m trying to keep a wordpress user base in sync with a third-party application. On a weekly basis, I’ll update the wordpress users. Is there any way to tell the script to compare the table and the csv file and make the table match the csv file, deleting users that aren’t in the csv file but in the table, adding users that are in the file but not the table, and ignoring those that are in both? It sounds ridiculous, but we have a very transient user-base at this org, having over 1000 employees and experiencing over 100% turnover per year.

    Thanks, again.

  7. Curtis,

    You are sort of correct .. you must remember the very first field is the login name .. so you really should split your users “Name” into first and last names.. you might find this page helpful in doing that in Excel ..

    http://office.microsoft.com/en-us/excel/HA011498511033.aspx

    Remember, the line to import must look like:

    login_name|Curtis Penner||mypassword|myemail|myrole

  8. Avatar Curtis Penner
    Curtis Penner says:

    Thanks for the quick reply Robert.

    Just so I’m clear…

    I have an excel spreadsheet with one column labeled as Name. Let’s say I have “Curtis Penner”.

    I could use the column labeled “Name” as “firstname” and leave the “lastname” field blank?

    So it would look like…

    Curtis Penner||mypassword|myemail|myrole

    I just want to clarify because your example has “fred|Fred Rivers|…and I wasn’t sure why “fred” would be there.

  9. Hello Curtis,

    You really can’t, these are stored in the database as separate items.. you could put both names into one field and just put an extra “|” in to represent the last name .. ie:

    fred|Fred Rivers||mypassw0rd|fred@rivers.com|Editor

    That would give you want you want, sort of but it users first name would be “Fred Rivers” whilst not having a last name.

  10. Avatar Curtis Penner
    Curtis Penner says:

    Hi Rob,

    Great plugin. It’s going to save loads of work. I have a question for you…

    If I wanted to eliminate the two name fields (first and last) and just make one field – “Name”, how would I make the modifications?

    Would I just delete all instances of “last name” and change “first name” to “name”?

  11. I’m curious, is there a way to import the usernames without sending them the users emails? Thanks.

  12. As Onetrick said, how can we actually export our WP users in the right format for the import to WPMU?

  13. Kenny,

    Sorry, sending of the email is something that wordpress does itself. It’s been a while since I’ve even looked at the script I can’t recall off hand if there is a way to prevent it.

  14. Thanks for the plug-in and it works so well for hundreds of ppl, but is there any way to stop acknowledging the user automatically? Since I would send email all new users with some other messages with an attachment like user guide 🙂
    Thansk again!

  15. Avatar onetrick
    onetrick says:

    Hello,
    I am trying to import 11,000 users from one wordpress installation to another. Your script and guide looks very promising however… what good is importing when I can not figure out how to export user data?!

    I’d like to have their username|email|password carried over at least. Everything would be better. I would appreciate it very much if you could help me a little bit with this one.

    Thank you!

  16. WordPress 2.8.4, still nothing…pasted in the data, but just switches back to Tools screen. Nothing imports…argh

  17. Thanks for making this available! It was exactly what I needed to import more than 1500 users from our old website into our MU setup.

    Thank you!

  18. I discovered what the issue was…all sorts of odd behavior (auto-generated passwords, some records not loading) due to the Register Plus plugin.

  19. Users are being added successfully, but the password is auto-generated in each case…instead of the password I’ve specified.

    Any idea why this would be happening?

    I love the concept of this plugin and would like to use it to save a day’s worth of manual user input.

  20. Avatar Francois
    Francois says:

    ok. It’s done with AutorDescription (sorry for my very bad english)
    Here : http://rapidechange.com/d/96707/2pMaYsZQ/dd-import-users-mod_wp27_v1.1.14.rar

    Usage :

    username|firstname|lastname|password|email|role|URL|Description

  21. Avatar Francois
    Francois says:

    Hello !
    Do you can hack this script also for “AutorDescription” ? It was very fantastic !
    Thank you !

  22. Avatar Terry Moore
    Terry Moore says:

    This script is exactly what I was looking for and needed. Thanks.

  23. I am running WP 2.8, and i am getting the following error:

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/thewood3/public_html/wp-content/plugins/Users-Import/Dagon Import users modifed Rob.php:320) in /home/thewood3/public_html/wp-content/plugins/wp-e-commerce/wp-shopping-cart.php on line 166

    Warning: Cannot modify header information – headers already sent by (output started at /home/thewood3/public_html/wp-content/plugins/Users-Import/Dagon Import users modifed Rob.php:320) in /home/thewood3/public_html/wp-content/plugins/sidebar-login/sidebar-login.php on line 258

  24. Ok, been playing with WPMU a little bit. Hacking the script to work specifically with MU looks like it will be .. well, non-trivial. However, take that as coming from someone that has crap PHP skills.

    While it’s not a “fix” it is a work around for doing imports into MU. It’s not really ideal but could be useful.

    1) Put the plugin into the /wp-content/mu-plugins/ directory, Deactivate and remove it from /wp-content/plugins/ first, it will barf on you

    2) Login into one of the blog sites myblog..com/wp-admin/ as an admin of that blog. Under Tools you’ll see the DDImport option.

    Accounts imported via the blog it self will be linked to that blog.

    Like I said it’s not idea and may not even be useful for some, but it will work. This will allow the blog owners the ability to import the users themselves, or mass create new accounts. This might be useful for the blog admin

    In the mean time I’ll keep poking around at the script and see if I can make it more MU friendly .. haha but it’s not gonna be easy, that I can see.

  25. Thanks for that, I’ve corrected the script. It was just a crazy fast cut/paste job.

    I’ve been looking at the WPMU registration process, I don’t think it will be an easy hack to make the script work with it, but I’ll have a play and see what I can do to it 🙂

    As the “new” script I posted is NOT for WPMU as it stands, I’ll actually just update the old script to the new one and include the changes.

  26. Pablo,

    I’m not sure it can be done without making some changes to the wp code. The actual function that’s called does the email along with the rest of the account creation, and there’s no option to “not send emails” in that function.

    It might be something to suggest to the WP code gods, add an option to not send emails just for scripts like this one, or even just as a one off check box, there are times when creating an account that you don’t need an email going out (ie: creating a test account).

  27. I don’t actually use WPMU so not sure about that feature. I’ve just has a fast look at registration.php from WPMU, perhaps the option you want to add is for user_url .. just hack the script and add that into

    $user_id = wp_insert_user(array(
    “user_login” => $ud[‘username’],
    “first_name” => $ud[‘firstname’],
    “last_name” => $ud[‘lastname’],
    “user_pass” => $password,
    “user_email” => $ud[’email’],
    “user_url” => $ud[‘url’]) // <– here
    );

    I'm not sure if that's the option or not for you. Try this new script with the changes adding user_url..

    http://www.gammaray-tech.com/scripts/dd-import-users-mod_wpmu27.txt

    Please be sure to try this on a dev system and NOT a live system!! I HAVE NOT TESTED THIS VERSION IN ANY WAY!!

    Please, re-read the last line again!!!

    • Avatar fluco
      fluco says:

      Thanks for your quick response Robert!

      The script had 2 syntax errors. The line above ud[‘url’] needed a “)” removed and required a “,”. Once that was fixed it ran fine. However, the variable user_url adds a url for the user’s website under contact information. What I’m looking for is to specify a default blog for the users imported. I’m not sure what variable would fix this as I’m not a programmer and am a newb to wpmu. Thanks again for your help.

  28. Avatar fluco
    fluco says:

    This is a great Plugin – Thank you! However, I’ve realized that it doesn’t apply the Dashboard Blog assigned in options. If I manually add a new user through the WPMU interface then the Dashboard Blog is assigned. Any ideas on how this can be fixed?

  29. Avatar Pablo
    Pablo says:

    Thanks Rob.

    But I have the same problem that Ankush has.

    I want to import 3000+ users, but don’t want to email them, is tehre any chando to do that?

    Thanks a lot.

  30. GiladG, Thanks for that. I’ve put the directory back. It seems to have gotten shuffled around when I was cleaning up. You always miss something when cleaning up don’t you 🙂

  31. Avatar GiladG
    GiladG says:

    Link to script is broken, any chance you can upload it back up?

  32. @ Ankush, I am looking to do the same thing. I have read elsewhere that the mailout function is done by WPs core code. So to stop it, we’d have to edit there and not just this nifty plugin.

    For the moment, I am stuck. I have phplist, which I have used in the past to do messages to my clients / subscribers, but since I have moved my site to a WP powered one, I don’t want to have two databases of users or force them to use two accounts to change their profiles.

    I’ll check back and post any solutions I find.

  33. Avatar Ankush
    Ankush says:

    Your plugin works wonderfully…thanks so much..you saved me a LOT of grief!!

    I am trying to import hundreds of users on my current blog to a new blog and I dont want to be spamming them with WP’s user/password emails. Would you happen to know how I am might temporarily disable that functionality??

  34. I need to be able to automate this (i.e. via cron).

    Would that be straightforward?

  35. Oh hooray! And thanks. I have to add around 350 subscribers and this has just worked perfectly with 4 names on my development blog.

    This is *exactly* what I needed. It’s much appreciated.

    Cheers,

    Miraz

  36. Rob, thanks a lot! Thats exactly what i need to import about 200 users. It works perfectly with WP 2.7.1 :-))

  37. Thanks very much. Glad it worked for you. It’s only fair I share the changes.. it came from the wild, it should be returned to the wild..

  38. Avatar Manvryn
    Manvryn says:

    Wow! You did an excellent work! Thank you very much! I installed as per your instructions and it worked perfectly! Thanks for sharing your modified script!

  39. You will need to install the plugin as any other plugin. No changes are needed to either the original script or my modified one. Once you install it you’ll see instructions for how to use it.

    Yes, it’s very much ready for 2.7, especially the changes I’ve made to it. Once installed you’ll find it under the Tools menu on the dashboard.

    Cheers!!!

  40. Avatar Manvryn
    Manvryn says:

    I think this is what I’ve been looking for, but, since I’m no expert, I have two questions:

    1- As I understand it, I have to install dagon design’plugin first, and then modify the php file. Am I right?
    2- Will this work foe WordPress 2.7?

  41. You are correct, thanks for that.. I’ve corrected the link on the site..

    Cheers!!!

  42. I think there’s a problem with the link… It’s generating an error as printed below:

    Fatal error: Call to undefined function add_action() in /var/www/virtual/gammaray/www.gammaray-tech.com/scripts/dd-import-users-mod_wp27.php.txt on line 316