Categories
Uncategorized

How to disable WordPress Admin Bar for All Users Except Administrators? « Acme Themes Blog


Do, you want to easily disable the admin bar in WordPress?

If your answer is yes, this is the perfect article for you. Here we’ll present you some of the ways to disable the WordPress admin bar for all users except administrators.

Firstly, let us know what WordPress Admin Bar is. If you’re new to this field you can check these WordPress tips and tricks to help you out.

WordPress users must be aware that WordPress displays an admin bar on the top for all the users who are logged-in. This toolbar is easily visible in all the pages you’re logged in and in the WordPress admin area as well.

Therefore, the admin bar can be distracting when viewing the public pages on the front-end of your website and may also affect user experience and the website’s design.

Fortunately, you can find multiple ways to easily disable the WordPress admin bar for all users except administrators.

Disable with the help of code

You can disable the admin bar for all the users except administrators by adding code to your WordPress theme files. It is a very simple and easy step. All you need to do is simply add the code given below to your theme’s function file or a site-specific plugin.

1

2

3

4

5

6

add_action('after_setup_theme', 'remove_admin_bar');

function remove_admin_bar() {

if (!current_user_can('administrator') && !is_admin()) {

  show_admin_bar(false);

}

}

After adding the code, it checks if the current user is not an administrator and if they’re engaged on the admin dashboard. Once both the condition matches, it will disable the WordPress admin bar.

Then, don’t forget to save changes and check your website and make sure everything is working fine.

Disable Admin Bar for all users including admins

With the help of the code below, you can even disable the admin bar for all the users including other administrators and even yourself on your site.

For that, all you need to do is simply modify the code and add the following code to the site-specific plugin or theme’s function.php file.

1

2

add_filter( 'show_admin_bar', '__return_false' );

This code mentioned above will help you to disable the admin bar for all the users when viewing the public pages of your website,

The users will still be able to see the toolbar inside the WordPress admin dashboard.

With the help of a plugin

Hide-Admin-Bar-Plugin

By using the plugin, you’ll be able to quickly and easily disable the WordPress admin for all users except admin.

Firstly, you should install the Hide Admin Bar Based on User Roles plugin and Activate it.

After the plugin is activated,

Step 1: Go to the Settings

Step 2: Go to Hide Admin Bar Settings page

Step 3: Then you can click the boxes next to user roles where you would like to disable the admin bar.

Lastly, click on the save changes button to store your settings.

Disable WordPress Admin Bar For any users:

WordPress permits each of the users to disable the admin bar by editing their own user profile. The site owner is also allowed to edit other users’ profiles and disable the admin bar. To disable the admin bar of the specific user in WordPress, you’ll need to edit their user profile.

Steps to be followed:

Step 1: Go to the Users

Step 2: Then All the Users page

Step 3: Click on the “edit” link for any specific user you want to disable the admin bar for.

After the following steps, this will bring you to the user profile editor page.

Step 4: Then, uncheck the box next to the ‘Show toolbar when viewing site’ option.

Step 5: Click on the “Update User” button to save your change.

After following the steps mentioned above, it will disable the admin bar for the specific user when visiting their site.

This method will not work if you have a large number of users, then you can physically disable the admin bar for all of them.


Conclusion

The ideas mentioned are very useful to disable WordPress Admin Bar for All Users Except Administrators. I hope this article will help you out.

If you liked this article, then consider following us on Twitter and Facebook, and LinkedIn.





Source link

Leave a Reply

Your email address will not be published. Required fields are marked *