For the beginners WordPress user roles and permissions may be a bit confusing and therefore, today I’m going to give you and overview what is what. Also, I’m going to show you how to add custom user roles on your WordPress site. Or better yet, how to clone user roles on WordPress.
So, let’s dive in.
Video: How to add and clone user roles in WordPress?
What are the default WordPress user roles and permissions?
By default Worpress has six different user roles. Here’s the brief overview of the roles and the permissions every role has.
Super admin user role
Super admins is available only if your have WordPress multi-site feature activated. This user role has access to all the network administration. It is the highest level for the user role. If you don’t have multisite acitvated then the Admin is the one with the highest level permissions.
Admin user role
As said above the Admin user role has the highest level of permissions. That is you can add users (even other admins), install plugins, delete content etc. This is the role that should be protected the most because if someones hacks your admin access you’re probably screwed.
Editor user role
This user role is useful if you have someone who does not have the need to access your site at admin level but who is responsible for managing your site content. Editor is the one who has a full control over the content but does not have permissions to install themes, plugins etc.
What separates editor from authors (see below) is that editors can add additional categories and they may moderate comments.
Author user role
Author user role is also for people who are hired for tasks related to content writing.
As said above authors cannot add additional categories and they cannot moderate comments. They can only add, edit and delete their own posts and nothing else.
Contributor user role
Contributor has even less permissions than authors. What they can do is:
- create their own posts without the option to publish them. Author user role has an option to publish directly.
- edit their own posts
- read all posts
Also, contributors don’t have permissions to upload images which means they can’t even add featured images to the posts.
Subscriber user role
Users with subscriber roles don’t have any permissions except:
- login to your site and
- update their user profiles
Subscriber does not have any publishing or editing permissions.
What are the default Woocommerce user roles and permissions?
If youinstall Woocommerce on your site then it will add two additional user roles to your site. So, let’s take a closer look at those roles.
Customer user role
All your new customers who create an accound during the checkout (or on My account page) will be assigned to the Customer user role. This role has basically the same permissions as Subscirber user role with the small difference.
The difference is that customer has an access to the orders history. That is they can see their orders (both past and current) and see their order statuses.
Shop manager user role
Shop manager user role is similar to the customer user role but it has additional permissons. Shop manager can:
- Manage Woocommerce settings
- Create/edit/delete products
- Manage Woocommerce orders
- Access reports
How to add custom user roles in WordPress?
There are two simple ways how to add custom user roles in Worpress that I’m going to show you. One of these methods uses plugin called Members and the other method uses a small code snippet.
How to add custom user roles with the Members plugin?
It is fairly simple and you need to follow these steps.
- Go to Plugins >> Add new and search for Members – Membership & User Role Editor Plugin
- Install and activate it
- Now you’ll see a Members >> Roles menu on the left. Open it up and you’ll see all the user roles you have on your site.
- If you want to add custom WordPress user roles with custom permissions then click on Add new role link or Add new button.
- This will open up your role permissions editor that you can use to set the appropriate capabilities for the user role. See the sceenshot below
- If eveything is ready then just press on Add role button and you’re done
How to add custom user roles in WordPress without a plugin?
Now let’s see how to add custom user roles in WordPress without a plugin. This time I will clone a user role with all the permissions it has.
If you are like me then you probably don’t like to use plugins for every simple thing. Just grab this piece of code here below and add it to your child theme’s functions.php file.
Or do as I do: I use Code Snippets plugin for adding all sorts of code snippets. Since I already use it for other small snippets on my site I will use that one. PS! After installing and activating the code you can delete it.
Where’s the code? See my next chapter here below..
How to clone user roles in WordPress?
There is two methods. One is with the help of Members plugin and another one is with the help of this code snippet here below. Let’s take a look at the code first.
How to clone user roles in WordPress without a plugin?
Let’s take a look at the code first because you can use this one for both adding or cloning your custom user roles.
// Clone user roles in WordPress
add_action('init', 'clone_wp_role');
function clone_wp_role() {
$adm = get_role('customer'); // replace the "customer" role if needed
$adm_cap= array_keys( $adm->capabilities ); //gets user role (customer) capabilities
add_role('bronze_member', 'Bronze package'); //creates my new role
$new_role = get_role('bronze_member');
foreach ( $adm_cap as $cap ) {
$new_role->add_cap( $cap ); //clone capabilities to new user role
}
}
Now, couple of things to point out.
- As you see I have a user role “customer” on the line 4. This is the user role I am going to clone. If you need to clone Editor user role then replace “customer” with “editor”.
2. On line 6 you need to replace ‘bronze_member’, ‘Bronze package’ accordingly if needed. For example ‘gold_member’, ‘Gold package’ will add a Gold package user role to your site. And this user roles has the permissions from the line 4
3. You need to paste the same slug ‘gold_member’ to the line 7
PS! After installing and activating the code once you can delete it.
How to clone user roles in WordPress with the Members plugin?
- Go to Plugins >> Add new and search for Members – Membership & User Role Editor Plugin
- Install and activate it
- Now you’ll see a Members >> Roles menu on the left. Open it up and you’ll see all the user roles you have on your site.
- Hover on the role name and you’ll see a Clone quick edito option (see the screenshot below). Click on Clone.
- This will open up your role permissions editor that you can use to modify the capabilities for the user role. Pay attention though that all the permissions and capabilites from the cloned roles is already selected.
- If eveything is ready then just press on Add role button and you’re done