Skip to content

Instantly share code, notes, and snippets.

@machouinard
Created June 20, 2018 21:22
Show Gist options
  • Save machouinard/d4ed43fa699647bfc7ca6387a91e6b72 to your computer and use it in GitHub Desktop.
Save machouinard/d4ed43fa699647bfc7ca6387a91e6b72 to your computer and use it in GitHub Desktop.
Remove unwanted menu items from main blog in WP multisite
function remove_menus() {
global $blog_id, $menu;
if ( $blog_id == '1' ) {
$restricted = array( 'Plans', 'Providers' );
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', 'remove_menus');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment