Add Custom User Role in WordPress Without Plugin

WordPress ships with five default user roles, and for many sites those five roles are enough. Sooner or later, though, most growing sites hit a gap. You want a team member who can review posts but cannot publish them. You want a shop assistant who can view orders but cannot change prices. You want a client who can edit pages but cannot install plugins. None of the default roles fits exactly, and giving someone a stronger role than they need is a security risk.
The good news is that you can add a custom user role in WordPress without a plugin, using a few lines of code. The function at the heart of this is add_role(), a built in WordPress function that registers a new role with the exact capabilities you choose. In this guide you will learn how it works, see two complete working code examples, learn how to assign the new role to a user, and learn how to remove a role safely when you no longer need it.
What Are the 5 Default WordPress User Roles?
Before you create a custom role, it helps to know what already exists. WordPress includes five default roles, arranged from least powerful to most powerful. If you are new to this system, read our guide that explains WordPress user roles and what each one can do first, because it covers each role in detail and will make the rest of this tutorial much easier to follow.
- Subscriber: can manage their own profile and read content. This is the lowest role, used for registered readers and members.
- Contributor: can write and edit their own posts, but cannot publish them or upload media. Their work waits for review.
- Author: can write, edit, publish, and delete their own posts, and upload media. They cannot touch other people’s posts.
- Editor: can publish, edit, and delete any post or page, moderate comments, and manage categories. They cannot install plugins or change settings.
- Administrator: has every capability. Admins can install plugins and themes, edit code, change settings, and manage all users.
What Does add_role() Do in WordPress?
The add_role() function registers a new role in the WordPress database. It takes three arguments: a machine readable role slug, a human readable display name, and an array of capabilities. Once the code runs, the new role appears in the Role dropdown on the Users screen, in the user profile editor, and anywhere else WordPress lists roles. You can then assign it to any user exactly like a default role. See the official add_role() documentation on developer.wordpress.org for the full argument list.
The first argument, content_reviewer, is the slug WordPress stores internally. Use lowercase letters and underscores only, and keep it short and descriptive. The second argument is the display name your team will see in the admin area, so make it clear, for example Content Reviewer or Shop Manager Lite. The third argument is the capabilities array, where each capability is set to true to grant it or false to withhold it. Only capabilities set to true are granted, so you can list just the ones you want and leave the rest out.
Before You Start: Back Up and Choose Where the Code Goes
You also need to decide where the code will live. You have two safe options. The first option is a child theme, by adding the code to the child theme functions.php file. Never add code to a parent theme, because a theme update will wipe it out. The second option, and the one we recommend for most beginners, is the free Code Snippets plugin, which lets you add PHP snippets from the WordPress admin area and turn them on and off with one click. That is still a plugin for running code, but the role itself is created with pure WordPress code and no role management plugin is needed. Choose whichever option you are comfortable maintaining, and stick with it so you always know where your role code lives.
Example 1: Create a Content Reviewer Role
function vtg_add_content_reviewer_role() {
add_role(
'content_reviewer',
'Content Reviewer',
array(
'read' => true,
'edit_posts' => true,
'edit_others_posts' => true,
'edit_published_posts' => true,
'upload_files' => true,
'publish_posts' => false,
'delete_posts' => false,
'delete_others_posts' => false,
)
);
}
add_action( 'init', 'vtg_add_content_reviewer_role' );
Let us walk through what each capability does. The read capability is essential for every role, because without it the user cannot even access the admin dashboard. The edit_posts capability lets the reviewer open posts in the editor. The edit_others_posts capability is the key one here, because it lets the reviewer edit posts written by other authors, which a normal Author cannot do. The edit_published_posts capability lets them revise posts that are already live, so they can fix errors after publication. The upload_files capability lets them add images to posts they are reviewing. The three capabilities set to false are the safety net: publish_posts is withheld so nothing goes live without an Editor, and the two delete capabilities are withheld so a reviewer cannot remove content by accident.
Example 2: Create a Shop Manager Lite Role for WooCommerce
function vtg_add_shop_manager_lite_role() {
add_role(
'shop_manager_lite',
'Shop Manager Lite',
array(
'read' => true,
'edit_posts' => true,
'upload_files' => true,
'edit_shop_orders' => true,
'read_shop_order' => true,
'edit_shop_order' => true,
'edit_published_shop_orders' => true,
'edit_product' => false,
'publish_products' => false,
'manage_woocommerce' => false,
)
);
}
add_action( 'init', 'vtg_add_shop_manager_lite_role' );
How Do WordPress Capabilities Work?
Capabilities are the individual permissions that make up a role. WordPress checks them every time a user tries to do something, from opening the Posts screen to clicking Publish. If the user current role includes the needed capability, WordPress allows the action. If not, WordPress hides the menu item or shows a permission error. This check happens on the server, so hiding a menu item with CSS is never a substitute for withholding the capability itself.
- read: access the admin dashboard. Every role needs this, even the most limited one.
- edit_posts and publish_posts: create and publish posts. Grant edit without publish for a reviewer workflow.
- edit_others_posts: edit posts written by other users. This is what separates a reviewer from an Author.
- edit_pages and publish_pages: the page equivalents of the post capabilities above.
- upload_files: add images and files to the Media Library. Without it, a user cannot add images to posts.
- moderate_comments: approve, spam, or delete comments. Useful for a community moderator role.
- manage_options: change site settings. Never grant this unless the person is a full administrator in practice.
How to Assign the New Role to a User
- Go to Users, then All Users, in the WordPress admin area.
- Click Edit under the user you want to change, or create a new user under Users, then Add New User.
- Find the Role dropdown and select your new role, for example Content Reviewer.
- Click Update User or Add New User to save the change.
- Ask the user to log out and log back in, so WordPress loads their new capabilities.
How to Remove a Custom Role with remove_role()
When a custom role is no longer needed, remove it with remove_role(). This function takes one argument, the role slug, and deletes the role from the database. Run it once, then remove the code again, because running remove_role() on every page load is wasteful and can cause confusion if the role is recreated by another snippet.
function vtg_remove_content_reviewer_role() {
remove_role( 'content_reviewer' );
}
add_action( 'init', 'vtg_remove_content_reviewer_role' );
Why Do Roles Persist After You Remove the Code?
This surprises many beginners. If you add a role with add_role(), then delete the code that created it, the role stays in the WordPress admin area. That is not a bug. WordPress stores roles and capabilities in the database, in the wp_options table under the wp_user_roles option, the first time add_role() runs. After that, the role exists in the database whether your code is still there or not. The code only needs to run once to register the role, and keeping it in place on the init hook simply makes sure the role is recreated if the database entry is ever lost.
Common Mistakes and Safety Warnings
Most custom role problems come from a small number of avoidable mistakes. The first is editing the parent theme functions.php file directly. A theme update replaces that file and your role code disappears, leaving you confused about why the role stopped being recreated. Always use a child theme or a code snippets manager. The second mistake is granting manage_options, install_plugins, or edit_users to a role that does not need them. Those three capabilities are effectively admin powers, and granting any of them defeats the purpose of a limited role. The third mistake is forgetting the read capability, which leaves the user unable to reach the dashboard at all. If a new user reports a blank admin area, check read first.
Security also matters beyond capabilities. Every extra user account is an extra login that could be attacked, so pair custom roles with strong account hygiene. Ask team members to use strong unique passwords, and protect the login page itself. Our guide on how to limit login attempts in WordPress without a plugin shows a code only method that slows brute force attacks, and our guide on how to change a WordPress username without a plugin helps you remove the predictable admin username that attackers try first. If your site runs on shared hosting and you are unsure about performance or security limits, our web hosting guide explains what to look for in a host that can support a growing team site.
Frequently Asked Questions
Do I need a plugin to add a custom user role in WordPress?
No. You can add a custom role with the built in add_role() function and a few lines of PHP in a child theme or a code snippets manager. A role editor plugin can make the process visual, but it is optional, and the code method gives you exact control over every capability.
Will my custom role disappear if I change my theme?
No, because roles are stored in the database, not in the theme. Changing the theme will not delete the role. However, if your role code lives in the old theme functions.php file, it will no longer run, so store the code in a child theme or a snippets manager that survives theme changes.
Can a user have more than one role at a time?
WordPress assigns one primary role through the admin screen, but a user can hold several roles in the database, and plugins or code can add extra roles. For most sites, one well chosen role per user keeps permissions simple and easy to audit, so avoid stacking roles unless you have a specific reason.
How do I fix a custom role that has the wrong capabilities?
Remove the role with remove_role(), update the capabilities array in your code, then let the code recreate the role with the corrected list. Do not rely on editing the code alone, because WordPress will not overwrite the stored role automatically. Always move users off the role first, then remove and recreate it.
Last updated: November 2026.



