I have to hide Administrator user role in the “User roles” area for these pages:
- /wp-admin/users.php
- /wp-admin/user-new.php
- /wp-admin/user-edit.php
I would like to hide this role option for other users that have an ability to select the Administrator role in order to prevent anyone other to give admin rights.
1
SOLUTION:
// Remove Administrator role from roles list
add_action( 'editable_roles' , 'hide_adminstrator_editable_roles' );
function hide_adminstrator_editable_roles( $roles ){
if ( isset( $roles['administrator'] ) && !current_user_can('level_10') ){
unset( $roles['administrator'] );
}
return $roles;
}