Languages: English • 日本語 (Add your language)
Remove a top level admin menu.
Please be aware that this would not prevent a user from accessing these screens directly. Removing a menu does not replace the need to filter a user's permissions as appropriate.
This function should be called on the admin_menu action hook. Calling it elsewhere could cause issues : either the function is not defined or the global $menu
variable used but this function is not yet declared.
<?php
function custom_menu_page_removing() {
remove_menu_page( $menu_slug );
}
add_action( 'admin_menu', 'custom_menu_page_removing' );
?>
Removes every menu for all users. To remove only certain menu items include only those you want to hide within the function. To remove menus for only certain users you may want to utilize current_user_can().
<?php function remove_menus() { remove_menu_page( 'index.php' ); //Dashboard remove_menu_page( 'jetpack' ); //Jetpack* remove_menu_page( 'edit.php' ); //Posts remove_menu_page( 'upload.php' ); //Media remove_menu_page( 'edit.php?post_type=page' ); //Pages remove_menu_page( 'edit-comments.php' ); //Comments remove_menu_page( 'themes.php' ); //Appearance remove_menu_page( 'plugins.php' ); //Plugins remove_menu_page( 'users.php' ); //Users remove_menu_page( 'tools.php' ); //Tools remove_menu_page( 'options-general.php' ); //Settings } add_action( 'admin_menu', 'remove_menus' ); ?>
(*) Better to add this priority if dealing with jetpack menu: add_action( 'admin_menu', 'remove_menus', 999 );
Since: 3.1.0
remove_menu_page() is located in /wp-admin/includes/plugin.php
.
Administration Menus: add_menu_page(), remove_menu_page(), add_submenu_page(), remove_submenu_page(), add_dashboard_page(), add_posts_page(), add_media_page(), add_links_page(), add_pages_page(), add_comments_page(), add_theme_page(), add_plugins_page(), add_users_page(), add_management_page(), add_options_page()