Creating and Managing User Roles in WordPress

creating and managing user roles

One of the best functions of WordPress is the ability to create and manage different user roles. The WordPress user roles create many different levels of engagement, from additional admins to contributors to customers. 

Learning and understanding user roles in WordPress will ease your workflow and help you manage your website. Continue reading to learn how to:

How to Add WordPress Users

The Types of User Roles

WordPress allows you to assign five different roles to users interacting with your website. Varying in access levels, each role gives the user needed permissions to complete their tasks. 

For example, you may have a user who only does editorial work or a writer who contributes to your blog. You can assign each the Editor and Contributor role respectively to allow them to complete their tasks without giving them full access to the dashboard. 

Below outlines the default WordPress user roles available:

RoleDescription
AdministratorSomebody with access to all the administration features within a single site
EditorA user who can publish and manage posts including the posts of other users
AuthorA user who can publish and manage their own posts
ContributorA user who can write and manage their own posts but cannot publish them
SubscriberA user who can only manage their profile

Adding a User in WordPress

Added WordPress users can help you manage, create, edit, and moderate your site operations and content. You can also have WordPress users who simply view and subscribe to your website. To add a new user, follow these steps:

  1. Log in to the WordPress Administrator Dashboard.
  2. Navigate to User > Add New.
  3. Fill in the required User Name and Email fields. The First Name, Last Name, and Website fields are optional.
  4. Under Role, choose the role you would like the user to have.
  5. WordPress can automatically generate a strong password for you. If you use this option, make sure the Send User Notification option is checked. This will send an email to your new user on how to log in. Otherwise, you will need to send the new user their login credentials through a method of your choice.
  6. Click Add New User to save the user.
add a new user role in WordPress

How to Change WordPress User Roles

Modifying roles in WordPress is a quick and easy task. You can do so easily by following the instructions below:

  1. Log in to the WordPress Dashboard.
  2. Navigate to User > Add New.
  3. Click on or hover over the user name, then click Edit.
  4. Scroll down Role, then click on the drop-down to view the available roles.
  5. Select the new role for your user. 
  6. Scroll down and click Update User to save your changes.

Customizing User Roles with the User Editor 

If the default WordPress user roles aren’t sufficient to run your website, with the User Role Editor plugin, you can create and manage custom user roles to your liking. 

A practical example for customizing a user’s role, would be to provide limited access to a Webmaster. They would be able to manage your comments, posts, and pages. However, they would not have access to change the site’s theme, plugins, and users. This is because of the custom capabilities granted per their assigned role. 

To get started, follow the instructions below.

Installing the User Role Editor Plugin

  1. Log in to the WordPress Dashboard.
  2. Navigate to Plugins > Add New.
  3. In the search field, type “user role editor“.
  4. Click the Install Now > Activate
  • download user role editor plugin
  • install user role editor

Using the User Role Editor Plugin

  1. Navigate to Users > User Role Editor.
  2. Click on the Select Role and change its capabilities drop-down box and choose the Role you want to change.
  3. Check the boxes to add additional capabilities to that role. In this example, we’re allowing Contributors to publish posts.
  4. You can select the Show capabilities in human readable form if you need help understanding the options.
  5. Once complete, to give capabilities to a specific person, click All Users, hover over the user, then click Capabilities.
  6. Once you have set your custom user roles, click Update to save them.
  • choosing the user role to edit
  • editing the user role
  • updating user role for user
  • editing user role for user

Managing User Roles Using WP-CLI

If you’re comfortable with the WordPress Command Line Interface (WP-CLI), then you can use the tool to create, customize, and manage your WordPress user roles without logging into WordPress. 

Learn how to use WP-CLI to create and manage WordPress user roles below.

Create a Custom Role

  1. SSH into your server as the cPanel user that owns the website.
  2. Use the cd command to switch into the document root directory of your website.

    Example:
    cd public_html/my_website

    NOTE: Be sure to replace public_html/my_website with the actual path to the document root directory of your website.
  3. Run the following command:
    wp role create $role-key $role-name

    Be sure to replace $role-key and $role-name with your own custom values. When the command completes running, a success message appears, as in the example output below:
[email protected] [~/public_html]# wp role create moderator Moderator Success: Role with key

Add Role Capabilities

  1. SSH into your server as the cPanel user that owns the website.
  2. Use the cd command to switch into the document root directory of your website.
    Example:
    cd public_html/my_website

    NOTE: Be sure to replace public_html/my_website with the actual path to the document root directory of your website.

  3. Run the following command:
    wp cap add $role $cap
    Be sure to replace $role and $cap with the capabilities (separated by a space) you want to allow for any user assigned that role. When the command completes running you should see a successful message, as in the example output below:

[email protected] [~/public_html]# wp cap add ‘moderator’ read edit_posts publish_posts upload_files edit_published_posts unfiltered_html read_private_pages edit_private_pages read_private_posts edit_private_posts publish_pages edit_published_pages edit_others_pages edit_pages edit_others_posts manage_links manage_categories moderate_comments
Success: Added 18 capabilities to ‘moderator’ role.

Assign a Role

Assigning a user role while creating a new user: 

  1. SSH into your server as the cPanel user that owns the website.
  2. Use the cd command to switch into the document root directory of your website.
    Example:
    cd public_html/my_website


    NOTE: Be sure to replace public_html/my_website with the actual path to the document root directory of your website.
  3. Run the following command:
    wp user create --prompt

    Refer to the table below for example values to respond with when prompted:
FieldDescriptionValue
1/10 <user-login>:Enter the username the new user will login with.wpadmin
2/10 <user-email>:Enter the email address to assign to the new user.[email protected]
3/10 [–role=<role>]:Enter the role to assign to the new user.moderator
4/10 [–user_pass=<password>]:Enter the password the new user will login with.@DMIN-p@s$w0rd123!
5/10 [–user_registered=<yyyy-mm-dd>]:Enter the date to set for the new user’s date of registration.2017-12-18
6/10 [–display_name=<name>]:Enter the new user’s name, as it should appear on the website.WP Admin
7/10 [–first_name=<first_name>]:Enter the new user’s first name.WP
8/10 [–last_name=<last_name>]:Enter the new user’s last name.Admin
9/10 [–send-email] (Y/n):Enter Y to send the new user details of the account via email or enter n to skip.n
10/10 [–porcelain] (Y/n):Enter Y to output just the new user id or enter n to skipn

Once you have responded to all the prompts, the user will be created and you will see a successful message, like in the example below:

[email protected] [~/public_html]# wp user create --prompt
1/10 <user-login>: wpadmin
2/10 <user-email>: [email protected]
3/10 [--role=<role>]: moderator
4/10 [--user_pass=<password>]: @DMIN-p@s$w0rd123!
5/10 [--user_registered=<yyyy-mm-dd>]: 2017-12-18
6/10 [--display_name=<name>]: WP Admin
7/10 [--first_name=<first_name>]: WP
8/10 [--last_name=<last_name>]: Admin
9/10 [--send-email] (Y/n): n
10/10 [--porcelain] (Y/n): n
Success: Created user 3.

Assigning a user role while updating a user: 

  1. SSH into your server as the cPanel user that owns the website.
  2. Use the cd command to switch into the document root directory of your website.

    Example:
    cd public_html/my_website

    NOTE: Be sure to replace public_html/my_website with the actual path to the document root directory of your website.
  3. Run the following command:
    wp user set-role $user $role
    Be sure to replace $user and $role with your actual user and your custom role. Once the user is set, you will see a successful message, like in the example below:
[email protected] [~/public_html]# wp user set-role wpadmin moderator
Success: Added wpadmin (3) to https://example.com as moderator.

In the next guide, we’ll show you How to Create an Admin Account in WordPress via MySQL. Learn more WordPress tips and tricks on our WordPress Education Channel!

InMotion Hosting Contributor
InMotion Hosting Contributor Content Writer

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

2 thoughts on “Creating and Managing User Roles in WordPress

  1. NO! It says nothing about how users keep appearing in my user list and why I can’t delete them!!!!!!!!!!!!!!!!!!!!!!!!

    1. Hello John,

      Thank you for your comment. Generally speaking, users should not appear in your user list unless you or another user with proper permissions adds a new user. If new users are being added automatically, it may be due to a plugin or it may be the result of malware on your site. I recommend reviewing your plugin list for any software that might potentially create users.

      Best Regards,
      Alyssa K.

Was this article helpful? Join the conversation!