Search code examples
wordpresswoothemes

Hide WooThemes menu from WordPress Admin


I'm using a WooThemes child theme and want to hide the menu from the WordPress admin bar. I use the following code so that only the users held within the array get to see all the options.

function remove_items_from_menu() {
$admins = array( 
    'Bill', 'Steve', 'Rob'
);
$current_user = wp_get_current_user();
 if( !in_array( $current_user->user_login, $admins ) ) {
         //   exit;
         add_filter('acf/settings/show_admin', '__return_false');

         remove_action('load-update-core.php','wp_update_plugins');

    remove_action( 'admin_notices', 'update_nag', 3 );
    remove_menu_page('edit.php?post_type=acf-field-group');
    remove_menu_page('edit-comments.php');
    remove_menu_page('tools.php');
    remove_submenu_page( 'index.php', 'update-core.php' );
    remove_menu_page('themes.php');
    remove_menu_page('plugins.php');
    remove_submenu_page( 'themes.php', 'themes.php' );
    remove_submenu_page( 'themes.php', 'widgets.php' );
    remove_submenu_page( 'themes.php', 'customize.php' );
    remove_submenu_page( 'themes.php', 'theme-editor.php' );
            remove_submenu_page('options-general.php', 'options-permalink.php');
            remove_submenu_page('options-general.php', 'options-media.php');
            remove_submenu_page('options-general.php', 'options-discussion.php');
            remove_submenu_page('options-general.php', 'options-reading.php');
            remove_submenu_page('options-general.php', 'options-writing.php');
            remove_submenu_page( 'options-general.php', 'social-sharing-admin' );    
}
}
add_action( 'admin_menu', 'remove_items_from_menu', 999 );

?>

Finding the page to hide for the theme displays itself as admin.php?page=woothemes, but adding the following line to the above code still doesn't hide it from view.

remove_menu_page('admin.php?page=woothemes');

Does anybody know how I can find out the correct page ID to hide this specific menu option? I've searched online and cannot find how to hide a WooThemes menu from the admin bar.

Thanks.


Solution

  • It depends on the id passed to add_menu_page when it was called by the WooTheme. You can search over the code, but I think that

    remove_menu_page('woothemes');
    

    should do it.

    Hope it helps.