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.

Usage

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

Examples

1. Remove role "subscriber":

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

Changelog

Since 2.0.0 Introduced.

Code of remove_role() WP 5.9.3

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