WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/remove role

Description

Removes a role from WordPress.

NB: This setting is saved to the database (in table wp_options, field wp_user_roles), so it might be better to run this on theme/plugin activation

Usage

 <?php remove_role$role ); ?> 

Parameters

$role
(string) (required) Role name
Default: None

Example

<?php remove_role( 'subscriber' ); ?>

to avoid calling remove_role when it's not needed you can check if the role exist

//check if role exist before removing it
if( get_role('subscriber') ){
      remove_role( 'subscriber' );
}

Notes

When a role is removed, the users who have this role lose all rights on the site.

Changelog

Source Code

remove_role() is located in wp-includes/capabilities.php.

Related

Roles and Capabilities:
See also index of Function Reference and index of Template Tags.