Hide user role from Dropdown selection
-
Hi there, thank you so much for this great plugin!
I’ve added a user role ‘dailyadmin’ based of the administrator role for daily admin tasks. They are allowed to add/edit users etc. Is there a way to hide the top level administrator user role from the dropdown selection? So the daily admin cannot pick the top level administrator role for the new user.
Thank you in advance!
I was already able to completely hide the ‘Additional Capabilities’ section using your code snippet from here and also the top level administrator from the user list using this code:
// START HIDE USER BASED ON USERNAME /* Hide user based on username */ add_action('pre_user_query','site_pre_user_query'); function site_pre_user_query($user_search) { global $current_user; $username = $current_user->user_login; if ($username == 'USERNAME') { } else { global $wpdb; $user_search->query_where = str_replace('WHERE 1=1', "WHERE 1=1 AND {$wpdb->users}.user_login != 'USERNAME'",$user_search->query_where); } } /* Display correct amount of users */ add_filter("views_users", "site_list_table_views"); function site_list_table_views($views) { $users = count_users(); $admins_num = $users['avail_roles']['administrator'] - 1; $all_num = $users['total_users'] - 1; $class_adm = ( strpos($views['administrator'], 'current') === false ) ? "" : "current"; $class_all = ( strpos($views['all'], 'current') === false ) ? "" : "current"; $views['administrator'] = '<a href="users.php?role=administrator" class="' . $class_adm . '">' . translate_user_role('Administrator') . ' <span class="count">(' . $admins_num . ')</span></a>'; $views['all'] = '<a href="users.php" class="' . $class_all . '">' . __('All') . ' <span class="count">(' . $all_num . ')</span></a>'; return $views; } // END HIDE USER BASED ON USERNAME
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Hide user role from Dropdown selection’ is closed to new replies.