Selectively Hide WordPress Admin Menu Items
When you are working with clients, there’s a great chance they aren’t very WordPress savvy and really, many of them don’t want to know the ins and outs of the system – well, not too much anyway. They just want to know enough to do what they have to do and get out of there.
The down side is, when you give someone an account inside their WordPress site, the options in the menu can be overwhelming. Like everything WordPress, this can be easily changed.
First, Set Your Role
Before doing anything drastic and go applying all sorts of plugins (it’s tempting, I know), give your user a role. It really depends how much control you want to give the client. Usually, if I feel the client is pretty net savvy and has some initiative, I’d allow them admin role. Otherwise, the max I’d give them is Editor. Check out the screen shots below to see what each role (other than admin) gets in their menu.
Editor |
Author |
Contributor |
Subscriber |
If those are sufficient for you, then you’ll have no need to anything else. The problem is, life isn’t always so simple. Add a few plugins the customer has to manage himself or if the client absolutely must manage users on their own, you really have no choice but to give them Admin role and do one of the following.
A. You can check out plugins like AG Custom Admin.
I really want to love this plugin. Tons of options and you can customize the admin a lot, even change your own branding which is sweet. In my test however, I’ve found it a little too confusing to get right.
Also, if you use a plugin with custom post types, when you hide the Post option, it also hides the Custom Post Type options. Why on earth would you want to hide the Post link? Because, I have a client for whom I developed a site that is driven completely with Pages & a Custom Post Type that I wrote. The client does not use Posts at all. My solution? Keep reading.
B. Manually edit out what users can/cannot see.
You can also manually add some code in your theme’s functions.php file. So here’s the code I used:
// Hide menus that are not needed for day to day
add_action('admin_init', 'ns_remove_admin_menus');
function ns_remove_admin_menus() {
global $menu;
global $current_user;
if ($current_user->ID != 1) {
remove_menu_page('edit.php');
remove_menu_page('link-manager.php');
remove_menu_page('ithemes-builder-theme');
remove_menu_page('plugins.php');
remove_menu_page('tools.php');
remove_menu_page('options-general.php');
}
}
A little explanation. The current_user_id part has a value of 1. You might want to replace that with your own admin account ID. By default, account #1 is almost always admin. This tells WordPress, if the user’s account ID is not ‘1’, then hide these pages.
The pages I’ve told it to hide are pretty straightforward. Edit is for Posts screen, link-manager is for Links, ithemes-builder-theme for iThemes’s Builder options, plugins for Plugins screen, tools for Tools and options-general for Settings. You can add more if you want e.g.
Option | Menu |
---|---|
upload.php | Media |
menuedit.php?post_type=page | Pages |
edit-comments.php | Comments |
themes.php | Appearance |
users.php | Users |
The second option is of course more technical and cumbersome to upkeep, but it is also the most flexible if you don’t mind working with it. Keep in mind though these simply hide the menus. They don’t actually restrict the user from accessing those if for whatever reason they followed a link to those those pages somewhere. However, I’ve found this simple method works wonders. Clients who aren’t that much into WordPress aren’t likely going to be snooping around to find hidden links anyhow so no point complicating your setup.
Do You Want A Hands-Free Business?
Then get this guide to help you systemize your business so you'll have more time working on your business.
Hey! I want to make sure you know what you're getting here. In addition to the guide, you will also receive our memo that includes special offers, announcements and of course actionable information.