How to Make WordPress Easier for Clients By Removing Unnecessary Menu Options

Contributing Editor

WordPress menu

In my previous WordPress posts we discovered how to create a plugin, change the administration panel branding, and remove unnecessary dashboard widgets and meta boxes.

In this post, we’ll make some fundamental changes to the main administration menu. If you haven’t created an initial plugin, please read the first part. Welcome back — let’s begin…

The standard WordPress menu can be a little daunting — and third-party plugins often add further items. You can restrict user roles so clients do not see all menu items but, unless you’re using every WordPress feature, they’ll still see options which don’t apply to their site.

We’ll create a function which removes redundant links and simplifies the experience for your clients. Here’s the full code which you can copy into easy-admin.php:


// remove unnecessary menus
function remove_admin_menus() {

	global $menu, $submenu;

	// main menus removed for all users
	$restrict = explode(',', 'Links,Comments');

	// sub-menus removed for all users
	$restrictsub = explode(',', 'Categories,Post Tags');

	// main menus removed for everyone except administrators
	$restrict_user = explode(',', 'Media,Profile,Appearance,Plugins,Users,Tools,Settings');

	// sub-menus removed for everyone except administrators
	$restrictsub_user = explode(',', 'Updates,My Sites');

	// WP localization
	$f = create_function('$v,$i', 'return __($v);');
	array_walk($restrict, $f);
	if (!current_user_can('activate_plugins')) {
		array_walk($restrict_user, $f);
		$restrict = array_merge($restrict, $restrict_user);
		array_walk($restrictsub_user, $f);
		$restrictsub = array_merge($restrictsub, $restrictsub_user);
	}

	// remove menus
	end($menu);
	while (prev($menu)) {
		$k = key($menu);
		$v = explode(' ', $menu[$k][0]);
		if(in_array(is_null($v[0]) ? '' : $v[0] , $restrict)) unset($menu[$k]);
	}

	// remove sub-menus
	foreach ($submenu as $k => $p) {
		foreach($submenu[$k] as $j => $s) {
			if (in_array(is_null($s[0]) ? '' : $s[0] , $restrictsub)) unset($submenu[$k][$j]);
		}
	}

}
add_action('admin_menu', 'remove_admin_menus');

The lines at the top of this function determine which menu items are removed:

  • $restrict (line 5) contains a comma-delimited list of main menu items which will not be shown to any users — including administrators. In the example above, we’re hiding Links and Comments since they’re not used in our site.
  • $restrictsub (line 7) contains a comma-delimited list of sub-menu items which will not be shown to any user. We’ve disabled Categories and Post Tags which normally appear in the main Posts menu.
  • $restrict_user (line 9) contains a comma-delimited list of main menu items which are hidden to everyone except administrators. The example above disables everything other than the Dashboard, Pages and Posts. (Non-administrators would not normally see Appearance and Plugins, but other plugins could change that functionality).
  • $restrictsub_user (line 11) contains a comma-delimited list of sub-menu items which are hidden to everyone except administrators. We’ve disabled Updates and My Sites which normally appear within the main Dashboard menu.

simplified WordPress menu

If you don’t want any items removed for a specific value, set it to an empty array, e.g. $restrict = array();

The result is a far simpler administration menu which is free of dangerous options which could confuse your clients.

Free book: Jump Start HTML5 Basics

Grab a free copy of one our latest ebooks! Packed with hints and tips on HTML5's most powerful new features.

  • http://www.facebook.com/people/Kay-Cee/100002469984318 Kay Cee

    Hi ! I need this badly .. thanks for sharing !

  • http://www.facebook.com/angela.poire Angela Poire

    This is awesome. Thank you for sharing!

  • http://www.atlantajones.com Andrew Jones

    Great stuff. But would this also prevent clients from seeing the WordPress “upgrade” alerts? We’ve had problems with clients just hitting that link, upgrading their WP and hosing their site :)

  • http://www.insurancegofer.com igofer

    That would work but its not my favorite idea….

    Thanks for sharing

  • Solucion Inteligente

    Hello.
    I am use plugins to disable many options, for example “updates” (which requires an expert: if it has been made ​​with a template)

    Now, this idea complete my preferences

  • http://gurusatap.wordpress.com/ guru satap

    wow… I understand many are not yet in WordPress, although I wordpres users. of this paper are very useful and beneficial for me.
    like this.
    tank’s..

  • http://www.web-first.co.uk Jon

    This is great but if a user knows the URL for the removed menu they can still load the page. Anyone know if there is there a way to completely remove access for some users? Cheers.

  • http://dish2u.com/ Dish2u

    As an Admin, it’s nice to gain greater control over user level access when sometimes just assigning an Editor or Contributor level either gives them too much or not enough access. Nice post Craig!

  • http://www.semidoppel.com Semidoppel

    Thanks for this tutorial, currently I am a blogger with a WP theme. I’m not good in HTML and stuffs alike..thanks again!

  • http://www.chrisfarrellmembershipsitereview.com/ Steve Balliett

    It never ceases to amaze me how customizable WordPress is.

    How remarkable it is to be able to adjust the platform to any way you want it to look. So cool.

    I keep it to the “Keep It Simple Smarty” method and help the visitor get a good viewing and site experience.

    I always try to put myself in their shoes while viewing a website. Like how I can make their visit as pleasing as possible.

  • http://www.howtomake.com.ua HTM

    man! this realy good ticket!