25 February 2022
Are you wondering how to hide the WordPress admin bar excerpt admin?
Although, by default, you can easily disable the WordPress admin bar for individual users. However, if your WordPress site has many registered users, it may take some time.
In this article, we’ll show you different methods for how to hide the WordPress admin bar for all users except administrators.
Let’s dive in!
The WordPress Admin Bar, also known as the Admin Toolbar, is a feature in WordPress that offers quick access to various administrative functions and tools while you are logged into the WordPress dashboard. It appears at the top of your site when you are logged in as an administrator or a user with appropriate permissions.
The Admin Bar includes a set of menus and shortcuts that allow you to perform various tasks without navigating through the WordPress dashboard. Some common elements found in the WordPress Admin Bar include:
There are two methods for hiding the WordPress admin bar. The easiest method is to install a plugin, whereas the difficult way is to manually insert a code snippet. We’ll show you both methods.
But, before we start, we strongly advise you to make a backup of your complete website. In this part, you will have to access the backend of your website and edit files, which is a dangerous business. Even adding a new plugin is not without risks since fresh installs have been known to cause website crashes. So, create a backup of your website right away.
Check out some backup plugins for WordPress you can use for your site if you haven’t one.
Once create your backup, let’s check out the different methods to disable the WordPress admin bar.
You can disable the admin bar for certain users by updating their user profiles. This is a quick and simple method for removing the bar for a small group of individuals. However, if you run a membership site with a large number of users, we advise a different approach.
To manually remove the admin bar, go to Users » All Users. Then, hover your cursor over the user who does not require the admin bar and click Edit when it appears.
This will bring up that user’s profile.
Next, uncheck the box next to the Show toolbar when viewing site option.
Then, scroll to the bottom of the screen and click Update User to save your changes. This will disable the admin bar for only that individual.
To hide the toolbar for more users, simply repeat the previous steps.
This method allows you to disable the WordPress admin for all users quickly.
First, you need to Install and Activate the Hide Admin Bar Based on User Roles plugin. For more details, see our guide on how to install a plugin in WordPress.
Upon activation, go to the Settings » Hide Admin Bar Settings page. Select the user roles you want to prevent from accessing the WordPress dashboard and Save your settings.
Installing and managing new plugins may be a headache. If you don’t like installing new plugins on your WordPress site, we suggest using the manual method of adding a code snippet to hide the WordPress admin bar.
Add the following code snippet to your theme’s functions.php file or a site-specific plugin.
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 whether or not the current user is an administrator and is not viewing the admin dashboard. If both requirements are met, the WordPress admin bar is disabled.
Remember to save your changes and verify your website to ensure that everything is working correctly.
You can hide the admin bar for all users, including the admin, by modifying the earlier code.
Copy and paste the below code snippet to your theme’s functions.php file or a site-specific plugin.
add_filter( 'show_admin_bar', '__return_false' );
This code will hide the admin bar for all users when viewing your website’s public pages. All users will still see the toolbar inside the WordPress admin dashboard.
The WordPress admin bar is a great tool, but it may sometimes cause more destruction than help. As a result, removing it may be a better option. You may always enable it by uninstalling the plugin or code snippet that helped you hide it in the first place.
If you do need to enable it, make sure to back up your site first before making any changes.
That’s it from this article.
For more, check out these other helpful resources:
Lastly, follow us on Facebook and Twitter to stay updated on the latest WordPress and blogging-related articles.