How to Make WordPress Easier for Clients, Part 2: Hiding Menus

Share this article

In part 1 of this series, we discovered how easy it is to simplify the WordPress interface for clients.

In this article, I describe a technique for hiding unnecessary menus. Why would we want to do that? The fewer options your client has, the less you’ll need to explain, the less they’ll need to remember, and the less likely they’ll do something, er … unexpected.

Before you add any code, I’d recommend you check your WordPress user roles. I suspect most developers add their client as an editor (publish and manage all posts) or an author (publish and manage their own posts). Avoid adding anyone as as administrator unless they specifically request that level of control.

Easier WordPressI’d also suggest you log in as that user and remove any unnecessary items using the Screen Options drop-down. Your client may not need to use features such as tags, slugs, or custom fields.

Now make a note of the menus the client doesn’t need. Options such as Profile, Tools and Settings are obvious candidates. Perhaps the site doesn’t use links or comments? Or should your client be able to manage posts but not static pages?

OK, so let’s add a little code to your theme’s function.php file. Not sure what that is? Take a look at part 1. Ready? Here’s the code:

// remove unnecessary menus
function remove_admin_menus () {
	global $menu;

	// all users
	$restrict = explode(',', 'Links,Comments');
	// non-administrator users
	$restrict_user = explode(',', 'Media,Profile,Appearance,Plugins,Users,Tools,Settings');

	// 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);

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

add_action('admin_menu', 'remove_admin_menus');

There are two lines you should edit:

  • $restrict (line 5) contains a comma-delimited list of menu items which will not be shown to any users — including adminstrators. In the example above, we’re hiding Links and Comments, but your requirements may be different.
  • $restrict_user (line 8) contains a comma-delimited list of menu items which will not be shown to non-adminisrators. The example above disables everything expect for the Dashboard, Pages and Posts. (Note that non-administive users would not normally see Appearance and Plugins, but other plugins might change that functionality.)

I hope you and your clients find it useful. Do you have further tips for simplifying WordPress?

Craig BucklerCraig Buckler
View Author

Craig is a freelance UK web consultant who built his first page for IE2.0 in 1995. Since that time he's been advocating standards, accessibility, and best-practice HTML5 techniques. He's created enterprise specifications, websites and online applications for companies and organisations including the UK Parliament, the European Parliament, the Department of Energy & Climate Change, Microsoft, and more. He's written more than 1,000 articles for SitePoint and you can find him @craigbuckler.

Share this article
Read Next
Get the freshest news and resources for developers, designers and digital creators in your inbox each week
Loading form