I’ve been working on WP User Manager for nearly a year now ( first code commit was February 17 2015 ). During development I quickly started running into those things that add up to a lot of time wasted.
Creating, updating and deleting multiple test users in WordPress is a very slow process. In the past, during my development test phases I just used the WP UI to create and update users because I couldn’t find a better way to do it.
Inspired by a recent talk about WP-CLI at the “A Day of Rest” conference in London last week, I decided to build a custom command to help me generate random users within WordPress and speed things up.
Welcome the “usergen” command.
wp-usergen-cli is a custom WordPress plugin that introduces a new “usergen” command within WP-CLI. You can download the plugin for free from github https://github.com/alessandrotesoro/wp-usergen-cli and install it like you would do with a normal WordPress plugin.
The generate subcommand can generate up to 1000 random users by default. The random data is retrieved from a json file within the plugin’s folder. The plugin will take care of generating username, password, email, first name and last name.
Mock data has been created with Mockaroo. If you need to generate more than 1000 users, use mockaroo.com to create your own json file and replace the existing one within the plugin’s folder. It’s important that you include all the default fields within your json file.
Use the generate subcommand followed by the number of users you need.
A progress bar will then appear showing the status of the generation.
Delete all users
The plugin also has a “purge” subcommand that when used will delete all users on the site excepts administrators.
The purge subcommand does not have any other parameter. Here’s an example:
A confirmation dialog will appear, once confirmed, multiple progress bars will appear for each user role detected within the site.
I hope you'll find this useful. If you have any suggestions, get in touch.