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