Stephen Balkum

Agile Enthusiast, Leader, and Developer

Creating WordPress users in bulk

no comment

On one of the WordPress sites I maintain, I found myself needing to create about 50 users. With a quick search, I found the needed functions are wp_create_user and wp_new_user_notification.  However, the sample scripts did not work.  Either the required WordPress bootstrap file was incorrect, or needed a path, or the wrong arguments were passed.  So, for everyone’s benefit, here is my very simple script:

<?php
require('/full/path/to/site/wp-blog-header.php');

// repeat the following two lines for as many more users as needed.
$user_id = wp_create_user('username', 'ClearTextPassword', 'user@emailaddress.net');
wp_new_user_notification($user_id, 'ClearTextPassword');
?>

The user will receive the standard announcement email. I used Excel to generate the needed lines and pasted them into the script.  Finally, I placed the script, named makenewusers.php, at the root of the site and pointed a browser at http://mysite.com/makenewusers.php.