Skip to content

WordPress Mass Account Import

  • by

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:

https://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 thoughts on “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?

    1. 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

      1. 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.

    1. 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 Penner

    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.

  8. 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.

  9. Curtis Penner

    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”?

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

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

  12. 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.

  13. 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!

  14. 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!

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

  16. 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!

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

  18. 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.

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

  20. 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

  21. 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.

  22. 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.

  23. 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).

  24. 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!!!

    1. 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.

  25. 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?

  26. 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.

  27. 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 🙂

  28. @ 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.

  29. 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??

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

    Would that be straightforward?

  31. 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

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

  33. 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..

  34. 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!

  35. 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!!!

  36. 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?

  37. 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

Comments are closed.