Create multiple users

Advertisement

Table of Content

Overview Overview

In this article we are going to see how to create multiple users with different user roles for testing the theme or plugin.

I am using WP CLI command wp user create to create the users.

If you don’t have WP CLI setup then read how to install WP CLI?

Okay. So, lets see how use wp user create command.

Top ↑

Syntax Syntax

wp user create <user-login> <user-email>

Here, We need to pass the username & email ID to create a new user. We have some different WP CLI associated arguments to set while creating the new user.

All of these associated arguments are optional.

--role=<role&tg;
--user_pass=<password&tg;
--user_registered=<yyyy-mm-dd-hh-ii-ss&tg;
--display_name=<name&tg;
--user_nicename=<nice_name&tg;
--user_url=<url&tg;
--nickname=<nickname&tg;
--first_name=<first_name&tg;
--last_name=<last_name&tg;
--description=<description&tg;
--rich_editing=<rich_editing&tg;
--send-email
--porcelain

Read more about wp user create.

Top ↑

Example Example

Lets create the administrator user with username test-administrator and password 12345.

wp user create test-administrator administrator@example.com --role=administrator --user_pass=12345

Now, Lets create contributor, editor, author & subscriber users with there associated user roles.

Use blow commands which create all these users.

wp user create test-contributor contributor@example.com --role=contributor --user_pass=12345
wp user create test-editor editor@example.com --role=editor --user_pass=12345
wp user create test-author author@example.com --role=author --user_pass=12345
wp user create test-subscriber subscriber@example.com --role=subscriber --user_pass=12345

After executing above command you can see something like below:

Create multiple user roles with WP CLI command.
Created multiple user roles with WP CLI command.

Create multiple users with wp user create command.

Leave a Reply