How To Remove Built-in User Roles In WordPress?

Subscriber, editor, author and contributor are built-in WordPress user roles. In case you have already created new user roles using popular User Role Editor or any other plugin and now you don’t need default WordPress user roles on your website. You can easily remove them by creating a new PHP function.

add_action('admin_menu', 'remove_built_in_roles');
 
function remove_built_in_roles() {
    global $wp_roles;
 
    $roles_to_remove = array('subscriber', 'contributor', 'author', 'editor');
 
    foreach ($roles_to_remove as $role) {
        if (isset($wp_roles->roles[$role])) {
            $wp_roles->remove_role($role);
        }
    }
}

If you wish to remove WordPress built-in user roles such as ‘subscriber’, ‘contributor’, ‘author’, ‘editor’, simply place the given code in your theme’s functions.php file or use Code Snippets plugin.

Now visit your admin area dashboard ‘Users’ section and check whether user roles are deleted. Once user roles are successfully removed from your website, delete this code off from your theme.

Also keep in mind that deleting ‘Administrator’ user role is not recommended. Only remove admin role if you have already created some new user role with admin capabilities, otherwise you might loose access to admin features on your website.

This works great on client website

After completing your client’s website and assigning a user role to him, you can delete admin and other user roles to make admin area interface easy and increase security of the website.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.