WordPress at a glance

remove_role() WP 2.0.0

Removes a role from WordPress.

These settings are saved in the database (wp_user_roles option of wp_options table), so it’s recommended to change them during activation/deactivation of a plugin or theme.


Null. Ничего.

Works based on: wp_roles(), WP_Roles()

No Hooks.


remove_role( $role );
$role(string) (required)
Role name. For example: administrator, editor, author, contributor, subscriber.


1. Remove role "subscriber":

register_deactivation_hook( __FILE__, 'myplugin_deactivate' );
function myplugin_deactivate(){
	remove_role( 'subscriber' );

Список изменений

С версии 2.0.0 Введена.

Code of remove_role() WP 5.5.1

function remove_role( $role ) {
	wp_roles()->remove_role( $role );

Related Functions

From tag: Roles capabilities

vladlu 100vlad.lu
Editors: kama 100
No comments
    Log In . Register