Skip to content

Instantly share code, notes, and snippets.

@aristath
Last active December 20, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aristath/6081378 to your computer and use it in GitHub Desktop.
Save aristath/6081378 to your computer and use it in GitHub Desktop.
<?php
/*
* This will remove the "Dashboard" menu item
* for all users that are not super-admins.
*/
function aristath_custom_admin_theme_remove_menus () {
if( !current_user_can( 'manage_network' ) ) {
global $menu;
$restricted = array( __( 'Dashboard' ) );
end ( $menu );
while ( prev( $menu ) ) {
$value = explode( ' ', $menu[key( $menu )][0] );
if( in_array( $value[0] != NULL?$value[0]:"" , $restricted) ) {
unset( $menu[key( $menu )] );
}
}
}
}
add_action('admin_menu', 'aristath_custom_admin_theme_remove_menus', 10);
<?php
/*
* This will disable the 'my-sites' menu
* for all users that are not super-admins.
*/
function aristath_remove_mysites_menu() {
global $wp_admin_bar;
if( !current_user_can( 'manage_network' ) ) {
$wp_admin_bar->remove_menu( 'my-sites' );
}
}
add_action( 'wp_before_admin_bar_render', 'aristath_remove_mysites_menu' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment