WordPress.org

Ready to get started?Download WordPress

Codex

Function Reference/remove menu page

Contents

Description

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.

Usage

<?php remove_menu_page$menu_slug ?>

Parameters

$menu_slug
(string) (required) The slug of the menu (typically the name of the PHP script for the built in menu items; example: edit-comments.php)
Default: None

Return Values

(array|boolean) 
The removed menu on success, false if not found.

Examples

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( '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' );
?>

Notes

  • Uses global: (unknown type) $menu
  • To remove submenu items in the admin, use remove_submenu_page. Using remove_menu_page() will not work for submenu items.

Change Log

Since: 3.1.0

Source File

remove_menu_page() is located in /wp-admin/includes/plugin.php.

Related

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()

See also index of Function Reference and index of Template Tags.