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.

No Hooks.

Return

null. Nothing (null).

Usage

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

Examples

0

#1 Remove role "subscriber":

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

Changelog

Since 2.0.0 Introduced.

remove_role() code WP 6.5.2

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