Change WordPress user roles and capabilities › Forums › Restrict or Permit access inside WordPress – how to › Delete default roles › Reply To: Delete default roles
11/02/2015 at 14:49
#1389
Vladimir
Keymaster
Hi,
It is one time operation. So create wp-content/mu-plugins folder, create there remove_built_in_roles.php file ant copy/paste code below to that file:
<?php
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);
}
}
}
It will remove all built-in roles except ‘administrator’ from your WordPress.
After you will see that roles were removed you may delete this file from mu-plugins folder.