How to hide menu on WordPress admin

I want to hide some menus on admin panel: Appearance, Plugins, and Tools.

How to hide it without plugin?

And how can I un-hide them later easily?

Solutions Collecting From Web of "How to hide menu on WordPress admin"

You can do this with remove_menu_page. Add the appropriate menu slug in your functions.php of your theme or your plugin.

<?php remove_menu_page( $menu_slug ) ?>

Note that users can still access these menus using a direct link. If you intend to block a user from accessing a menu, you will have to set up a user role and make sure they don’t have the relevant capabilities.

Here is a list of slug examples for the menus included in a clean WordPress install.

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

can do it with remove_menu_page()
try out these locations

Remove Menu Item in WordPress Admin Panel

Remove Unwanted Items from the WordPress Admin Sidebar

This is a nice chunk of code from Bill Erickson’s Core Functionality plugin.

/**
 * Remove Menu Items
 * @since 1.0.0
 *
 * Remove unused menu items by adding them to the array.
 * See the commented list of menu items for reference.
 *
 */
function ni_remove_menus () {
    global $menu;

    // Example:
    //$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins'));
    end ($menu);
    while (prev($menu)){
           $value = explode(' ',$menu[key($menu)][0]);
           if(in_array($value[0] != NULL?$value[0]:"" , $restricted) {
               unset($menu[key($menu)]);
           }
    }
}
add_action( 'admin_menu', 'ni_remove_menus' );

Uncomment the restricted array and include the menu items you’d like to hide. The example contains all the menu items for reference.