Remove Menus in WordPress

Over the years, I have had to work with a lot a different levels of clients with varying skills. One thing that is always asked is “What happens when I screw something up?” Well I have ways of backing up everything which I will go into at a later date. What I prefer to rely on though is preventing that from becoming an issue.

There are a multitude of plugins that allow you to hide elements of the User Menu in the WordPress Dashboard. Some free and some paid. Personally, I like to go with a much simpler solution that works wonderfully. Start off by opening up your text editor and copy the following code into it:


<?php
/*
Plugin Name: Remove Menus
Description: Removes unused menu items
Version: 0.1
License: GPL
Author: Brian Stoiber
Author URI: http://brianstoiber.com
*/

add_action( 'admin_menu', 'my_remove_menu_pages' );
<span style="font-style: normal; line-height: 1.5;">
  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
 }
?>

Delete the lines of the menu items you don’t want to hide and save this file to your plugin directory. Once there head over to the Plugin menu in the WordPress Dashboard. Look for the plugin “Remove Menus” and Activate it.

NOTE: This will hide the menus from yourself too. I don’t find this to be a problem because all you need to do is navigate to http://www.domainname.com/wp-admin/plugins.php and Deactivate it to temporarily unhide it. Make your changes and then hide it again.

This might not be the perfect solution for you but I don’t see a reason to install a full plugin with 20+ files in it to do what you can do in 20 lines of code