How to Disable WordPress Admin Bar for All Users Except Administrators?

0
166

Do you want to learn the way to disable the WordPress admin bar?

WordPress allows you to easily disable the admin bar from the dashboard by default. Unfortunately, this method will not come to action if there are a lot of registered users on the site and takes a lot of time as well.

Luckily, there are several methods to help you out. We will cover the three easiest different methods i.e manually, using plugins, and using codes as well to disable the WordPress admin bar. 

What is WordPress Admin Bar?

Having proper knowledge about the admin bar is a must in order to disable the WordPress admin area. Admin bars are the bars that are displayed at the very top of the screen that reveals sites’ name, comments, and more.

By default, WordPress reveals the admin bar to all the users that are logged in to the identical page as well as the admin area. Additionally, the presence of the admin bar at the top of the front-end distracts the viewer and also has an adverse effect on your website’s design and user experience.

Let’s move on to the different methods to disable WordPress Admin Bar for All Users Except Administrators.

1. Disable WordPress Admin Bar for All Users Except Administrations Using a Plugin

This is an easy and fast method to disable the admin bar. Follow the step mentioned below:

Install and activate the Hide Admin Bar Based on User Roles plugin. 

After activation, navigate to Settings >> Hide Admin Bar Settings page.

On this page, click on the boxes to whom you want to disable the admin bar beside the User Roles.

Don’t forget to click on the “Save Changes” tab.

2. Disable WordPress Admin Bar for All Users Except Administrations Using Code

This method is not recommended for beginners as small errors can cause the downfall of the entire system. However, if you want to easily add custom code without the risk of the breakdown of the system, you can go through our tutorial “How to Easily Add Custom Code in WordPress?

Before adding custom code, make sure you work on the child theme. Next, all you need to do is copy the codes mentioned below into your function.php file:

add_action(‘after_setup_theme’, ‘remove_admin_bar’);

function remove_admin_bar() {

if (!current_user_can(‘administrator’) && !is_admin()) {

  show_admin_bar(false);

}

}

Don’t forget to save the changes. Thus, you can monitor your website after adding custom code to check the performance of the code. 

The above-mentioned two methods are applicable for all the sites having many as well as few logged-in users.

3. Disable Admin Bar for Any User

Basically, this method is for the one who wants to disable the admin bar for particular users. However, as a site owner, you need to edit the profile of the particular user to disable the admin bar. Here are the steps:

  • Firstly, navigate to Users >> All Users. Next, click on the “Edit” link of the selected user to disable the admin bar.
  • Now user profile page will appear where you need to uncheck the box next to the “Show toolbar when viewing site” option.
  • Make sure you click on the “Update User” tab to save the changes.

Note: This method might not work for a membership site having alot of users logged in. In such a case, you have to manually disable the admin bar for all the users leaving the administrator like in the methods mentioned above.

4. Disable Admin Bar for all Users

Sometimes you would like to disable the admin bar for all the users including the admin too. In this case, you are ought to follow this method. The method is simple and easy but consists of code. So, make sure you work on the child theme. 

Like in method 2, all you need to do is add the code into our function.php file or a site-specific plugin. Here you are with the codes:

/* Disable WordPress Admin Bar for all users */

add_filter( ‘show_admin_bar’, ‘__return_false’ );

Hence, you have disabled the admin bar for all the users in the easiest manner. 

Wrapping up

Lastly, we hope this tutorial was helpful for you. Undoubtedly, we have mentioned the easiest ways to disable the admin bar, you can apply any method which fulfills your requirement. Also. go through our other article “How to Add and Customize Admin Columns in WordPress?” to have more information about admin areas. 

LEAVE A REPLY

Please enter your comment!
Please enter your name here