This is a small code I wrote to batch create generic users
<?php $lock = true; //true = disabled (locked)
if(!$lock) { // if not locked
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
$last_registered_user = $wpdb->get_row("SELECT ID FROM $wpdb->users ORDER BY ID DESC LIMIT 1");
$new_id = $last_registered_user->ID + 1;
$limit = false; // extra lock
while($new_id <= $limit) {
wp_create_user( 'user_'.$new_id, 'changeme', 'user'.$new_id.'@example.com' );
$new_id++;
}
} else { // if locked ?>
<h5>This script is locked to prevent accidental use.</h5>
<?php
}
?>
Setup
A couple things to do:
- Change unlock the script by setting
$lock
to false. - Change the path to
wp-load.php
. - Change
$limit
to the number of users you want to create.
Use
This script will create $limit
number of users with the username user_andTheirID
and their e-mail address [email protected]
. To edit the username, once the users have been created, you will have to edit the database itself.
Extra
If you want users to change their passwords from the default, changeme
, try the Force Password Change plugin by Simon Blackbourn. This will require users to change their password on their first log in. Make sure you install this plugin BEFORE you run the batch create, otherwise the right values will not be created for the existing users.