Skip to content

Instantly share code, notes, and snippets.

@ckaklamanos
Created May 31, 2020 16:27
Show Gist options
  • Save ckaklamanos/6d8d0a672a08e1784441884ccdc2d2ad to your computer and use it in GitHub Desktop.
Save ckaklamanos/6d8d0a672a08e1784441884ccdc2d2ad to your computer and use it in GitHub Desktop.
WordPress: Hide Dashboard Menus and ubmenus apart from Menu (for non- Administrators)
function fn_hide_dashbaord_menus_and_subemenus(){
//Posts
remove_menu_page( 'edit.php' );
//WoocOmmerce settings
remove_submenu_page('woocommerce', 'wc-settings');
remove_submenu_page('woocommerce', 'wc-addons');
remove_submenu_page('woocommerce', 'wc-status');
remove_menu_page('wc-admin&path=/marketing');
// More here
// https://plugintests.com/plugins/woocommerce/tips
//Appearance
remove_submenu_page( 'themes.php', 'themes.php' ); // hide the theme selection submenu
remove_submenu_page( 'themes.php', 'widgets.php' ); // hide the widgets submenu
//remove_submenu_page( 'themes.php', 'nav-menus.php' ); // hide the widgets submenu
remove_submenu_page( 'themes.php', 'customize.php?return=' . urlencode($_SERVER['SCRIPT_NAME'])); // hide the customize submenu
remove_submenu_page( 'themes.php', 'customize.php?return=' . urlencode($_SERVER['REQUEST_URI'])); // hide the customize submenu
// Specific to Astra Thhme
remove_submenu_page( 'themes.php', 'edit.php?post_type=astra-advanced-hook');
remove_submenu_page( 'themes.php', 'edit.php?post_type=astra_adv_header');
remove_submenu_page( 'themes.php', 'edit-tags.php?taxonomy=bsf_custom_fonts');
}
if (!current_user_can('manage_options')) {
add_action('admin_head','fn_hide_dashbaord_menus_and_subemenus');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment