Change WordPress user roles and capabilities › Forums › Give user access to plugin – how to › Disable editing user roles on users page. › Reply To: Disable editing user roles on users page.
05/08/2018 at 12:52
#5068
Vladimir
Keymaster
Try to install this code (theme’s functions.php or Must Use plugin):
add_filter('ure_users_select_primary_role', 'my_users_select_primary_role', 10, 1);
function my_users_select_primary_role($select) {
$user = wp_get_current_user();
if (in_array('user-manager', $user->roles)) {
$select = false;
}
return $select;
}
add_filter('ure_show_additional_capabilities_section', 'ure_show_additional_capabilities_section');
add_filter('ure_bulk_grant_roles', 'ure_show_additional_capabilities_section');
function ure_show_additional_capabilities_section($show) {
$user = wp_get_current_user();
if (in_array('user-manager', $user->roles)) {
$show = false;
}
return $show;
}
Replace ‘user-manager’ with your own user role ID.