How to Disable WordPress Admin Bar for All Users Except Administrators

Disabling the WordPress admin bar for a single user is fairly easy. You simply open the dashboard and pinpoint the user that should no longer have access to it. Unfortunately, doing so for all users except administrators is practically impossible. Therefore, in this article, we will explore some extra methods to disable WordPress Admin Bar for all users except administrators.

WordPress Admin Bar 101

For those that are completely new to WordPress, we will first explain what the admin bar is. Put simply, the admin bar is the toolbar that shows at the top of your screen once you log into your WordPress. By default, the admin bar is shown to all logged-in users and it is visible on all pages within your WP website. It contains various tools and shortcuts for different sections of your website. Although, not all shortcuts are available to all users.

+ New tool opened in WordPress admin bar.
Some tools are quite useful to users, which is why you should think twice before you Disable WordPress Admin Bar for all users except administrators.

So, with this in mind, why should one bother with disabling the WordPress Admin Bar for all users except administrators? Well, most users have no need for the admin bar. As it stands it can often be distracting, and can even cause confusion if the user misclicks. Furthermore, it can ruin the user experience, especially if the bar clashes with the website’s design. Not to mention that by doing so you are increasing your website’s security. So, let’s explore how to properly disable the WordPress Admin Bar for all users.

Methods to disable WordPress Admin Bar for all users except administrators

If you have only a handful of users, you can use the manual method to disable the Admin Bar for them. This is done by simply visiting the Users -> All Users page and clicking on “edit” for whatever user you want to disable. Clicking on “edit” will take you to the profile editor page where you can uncheck the “Show toolbar when viewing site” box. All you need to do now is scroll to the “Update User button and save.

Manually disabling the admin bar works if you have a small number of users. But, if you are operating with a larger number, you will have to resort to other methods. Luckily, these methods are fairly straightforward, especially if you have some prior experience with WordPress functionality.

Using a plugin

As it is with most issues related to WordPress, there is a plugin that can help you out. As always, we do advise you to make a backup of your website before installing any plugin. Even simple plugins can have unforeseen interactions with WordPress. And, while you probably can uninstall the problematic plugin if something goes wrong, the easier thing is to simply make a backup and revert to it if necessary.

The plugin you are looking for to solve this issue is Hide Admin Bar Based on User Roles. The installation process is fairly standard, which is why we will assume that you’ve successfully tackled it. Once you have the plugin installed and activated head on to the Setting -> Hide Admin Bar Setting page. There you will find different checkboxes controlling from whom the admin bar should be hidden. In this instance, you want to select everyone but the Administrator, and click on Save Changes. This should ensure that your admin bar is disabled for all users except administrators.

Using code

While plugins are fairly useful, more experienced WordPress users opt for using code whenever possible. Doing so is usually a cleaner way to alter WordPress, as you don’t have to rely on optimization of the plugin that you’ve installed. Furthermore, it also adds to the overall minimalism of your website. If you haven’t added code to WordPress before, don’t worry. It’s not like you have to code a landing page from scratch. In fact, the process of adding code so is surprisingly simple. The first thing to do is to copy the following code:


add_action(‘after_setup_theme’, ‘remove_admin_bar’);
function remove_admin_bar() {
if (!current_user_can(‘administrator’) && !is_admin()) {
show_admin_bar(false);
}
}


The second step is to paste the code into the functions.php file. After that, all you need to do is to save your changes.

Lines of code related to website design, showing one way in which you can disable WordPress Admin Bar for all users except administrators.
People often fret about using code to alter WordPress. Meanwhile, doing so is surprisingly easy and efficient.

For those who want to know more, what the code does is that it checks whether the current user is not an administrator and whether they are not currently viewing the admin dashboard. If both conditions are met, the code will disable the WordPress admin bar.

Disabling for all users including admins

As an extra feature, we are going to explain to you how to completely disable the admin bar, even for administrators. Here, again, the process is fairly straightforward. If you’ve installed the plugin we’ve mentioned, you already have the checkbox for doing so. If you opted for coding, all you have to do is to modify the previous code a bit. Open the function.php file, and add the following code:


add_filter( ‘show_admin_bar’, ‘__return_false’ );


The code that you’ve copied will effectively disable the admin bar for all users, including administrators. Keep in mind that this will apply to all public pages on your website. If you wish to use tools from your admin bar, you can do so from the WordPress admin dashboard.

A word of caution

Since we’ve covered numerous “how to ways to alter WordPress” in various articles, we do feel a need to say out a word of caution. While WordPress does have a ton of plugins and codes that alter it, you should implement them wisely. Too often, administrators are quick to remove tools that users could find useful. On the other hand, they change existing tools believing that the new version will be easier to use while ignoring the fact that the users have grown accustomed to the tools they are using.

A frustrated girl looking at a laptop.
Avoid frustrating people that help you run your website.

So, before you disable WordPress Admin Bar for all users except administrators, try to do so with ample forethought. Otherwise, you risk detriment your user’s experience of your website.

Newsletter