Do you want to easily disable the admin bar in WordPress?
By default, you can easily disable the WordPress admin bar for any user from the dashboard. But this method can take time if you have a lot of registered users on your site.
In this article, weβll show you how to disable the WordPress admin bar for all users except administrators.
What is WordPress Admin Bar?
By default, WordPress displays an admin bar on the top for all logged-in users. This toolbar is visible in the WordPress admin area as well as all other pages when you are logged in.
The WordPress admin toolbar contains useful shortcuts to different WordPress sections. The shortcuts available in the admin bar change based on a usersβ role and permissions in WordPress.
However, when viewing the public pages on the front-end of your website, the admin bar can be a bit distracting. It may also affect your websiteβs design and user experience.
Luckily, there are multiple ways to easily disable the WordPress admin bar for all users except administrators.
If youβd prefer written instructions, just keep reading.
Method 1. Disabling The WordPress Admin Bar for Any User
WordPress allows each user to disable the admin bar by simply editing their user profile. As a site owner, you can also edit other userβs profiles and disable the admin bar for them.
If you want to disable the admin bar for any particular user in WordPress, youβll need to edit their user profile.
Simply go to the Users Β» All Users page and then click on the βeditβ link for any user you want to disable the admin bar for.
This will bring you to the user profile editor page. From here, uncheck the box next to the βShow toolbar when viewing siteβ option.
Scroll down and click the βUpdate Userβ button to save your changes.
This will disable the admin bar for that particular user when they visit the website.
If you have a handful of users, then you can go ahead and manually disable the admin bar for all of them. However, if you run a membership site with a lot of users, then this method wouldnβt work.
Luckily, there are other ways to quickly disable the admin bar for all users except administrators.
Method 2. Disable Admin Bar for All Users Except Admins with a Plugin
This method allows you to quickly disable the WordPress admin for all users.
First, you need to install and activate the Hide Admin Bar Based on User Roles plugin. For more details, see our step by step guide on how to install a WordPress plugin.
Upon activation, go to the Settings Β» Hide Admin Bar Settings page. From here, check the boxes next to the user roles where you want to disable the admin bar.
Donβt forget to click on the βSave Changesβ button to store your settings.
Method 3. Disable Admin Bar for All Users Except Administrators Using Code
This method requires you to add code to your WordPress theme files. If you have not done this before, then check out our guide on how to copy and paste code snippets in WordPress.
Simply add the following code to your themeβs functions.php 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); } } |
This code checks if the current user is not an administrator, and they are not viewing the admin dashboard. If both conditions match, then it will disable the WordPress admin bar.
Donβt forget to save your changes and check your website to make sure everything is working fine.
Method 4. Disable Admin Bar for All Users Including Admins
What if you wanted to disable the admin bar for all users including yourself and any other administrator on your site?
You can do this by modifying the code we showed earlier.
Simply add the following code to your themeβs functions.php file or a site-specific plugin.
1 2 | /* Disable WordPress Admin Bar for all users */ add_filter( 'show_admin_bar' , '__return_false' ); |
This code will disable the admin bar for all users when viewing the public pages of your website. All users will still be able to see the toolbar inside the WordPress admin dashboard.
We hope this article helped you learn how to disable the WordPress admin bar for all users except administrators. You may also want to see our ultimate WordPress security guide and our comparison of the best WordPress page builder for creating custom page layouts without any code.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.