How to create new user role in wordpress

To create a new user role in WordPress, you can follow these steps:

Method 1: Using the WordPress Dashboard

  1. Log in to your WordPress dashboard.
  2. Click on Users in the left-hand menu.
  3. Click on Add New at the top of the page.
  4. Enter a name for the new role in the Role Name field.
  5. Click Add Role.

Method 2: Using the WordPress Code Editor

  1. Log in to your WordPress dashboard.

  2. Click on Appearance in the left-hand menu.

  3. Click on Editor.

  4. In the editor, navigate to the wp-content/plugins/users-role-editor/users-role-editor.php file (or create a new file with this name if it doesn't exist).

  5. Add the following code to the file:

    <?php
    function add_new_role() {
     $role = new WP_Role('new_role_name');
     $role->add_cap('read');
     $role->add_cap('edit_posts');
     // Add more capabilities as needed
     return $role;
    }
    add_action('init', 'add_new_role');
    ?>

    Replace new_role_name with the name you want to give to the new role.

  6. Save the file.

Method 3: Using a Plugin

There are several plugins available that allow you to create new user roles in WordPress, such as:

To use one of these plugins, follow these steps:

  1. Install and activate the plugin.
  2. Go to the plugin's settings page (e.g. User Role Editor > Settings).
  3. Click on the Add New Role button.
  4. Enter a name for the new role and add the desired capabilities.
  5. Click Add Role.

Additional Tips