How to remove entire admin menu?

The correct hook to use is admin_menu and then create a function to remove the menus you want to remove. The following 2 functions remove all the menus.

add_action( ‘admin_menu’, ‘remove_admin_menus’ );
add_action( ‘admin_menu’, ‘remove_admin_submenus’ );

//Remove top level admin menus
function remove_admin_menus() {
remove_menu_page( ‘edit-comments.php’ );
remove_menu_page( ‘link-manager.php’ );
remove_menu_page( ‘tools.php’ );
remove_menu_page( ‘plugins.php’ );
remove_menu_page( ‘users.php’ );
remove_menu_page( ‘options-general.php’ );
remove_menu_page( ‘upload.php’ );
remove_menu_page( ‘edit.php’ );
remove_menu_page( ‘edit.php?post_type=page’ );
remove_menu_page( ‘themes.php’ );
}

//Remove sub level admin menus
function remove_admin_submenus() {
remove_submenu_page( ‘themes.php’, ‘theme-editor.php’ );
remove_submenu_page( ‘themes.php’, ‘themes.php’ );
remove_submenu_page( ‘edit.php’, ‘edit-tags.php?taxonomy=post_tag’ );
remove_submenu_page( ‘edit.php’, ‘edit-tags.php?taxonomy=category’ );
remove_submenu_page( ‘edit.php’, ‘post-new.php’ );
remove_submenu_page( ‘themes.php’, ‘nav-menus.php’ );
remove_submenu_page( ‘themes.php’, ‘widgets.php’ );
remove_submenu_page( ‘themes.php’, ‘theme-editor.php’ );
remove_submenu_page( ‘plugins.php’, ‘plugin-editor.php’ );
remove_submenu_page( ‘plugins.php’, ‘plugin-install.php’ );
remove_submenu_page( ‘users.php’, ‘users.php’ );
remove_submenu_page( ‘users.php’, ‘user-new.php’ );
remove_submenu_page( ‘upload.php’, ‘media-new.php’ );
remove_submenu_page( ‘options-general.php’, ‘options-writing.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-discussion.php’ );
remove_submenu_page( ‘options-general.php’, ‘options-media.php’ );
remove_submenu_page( ‘options-general.php’, ‘options-privacy.php’ );
remove_submenu_page( ‘options-general.php’, ‘options-permalinks.php’ );
remove_submenu_page( ‘index.php’, ‘update-core.php’ );
}
Screenshot of left menu using the above 2 functions:

enter image description here

shareimprove this answer
edited Sep 27 ’13 at 6:02

answered May 15 ’12 at 3:09

Chris_O
13.9k22360
1
I did find another way by using $GLOBALS[‘menu’] = array();. Giving null in the array will also do the work. – dev-jim May 15 ’12 at 11:13

Where do you put this? – user26728 Jul 17 ’13 at 14:22

Anyone noticed the recent drafts from that screen shot? 😉 – acSlater Sep 24 ’13 at 15:02
add a comment

up vote
2
down vote
Following the lead of /wp-admin/admin-header.php -> /wp-admin/menu-header.php there’s no hook to do it.

A solution is to hook in admin_head and do some CSS + jQuery

add_action(‘admin_head’, ‘wpse_52099_script_enqueuer’);
function wpse_52099_script_enqueuer(){
if(!current_user_can(‘administrator’)) {
echo < < #wpcontent, #footer { margin-left: 0px; }


HTML;
}
}

http://wordpress.stackexchange.com/questions/52099/how-to-remove-entire-admin-menu

Deixe um comentário