Remove WordPress admin bar for all users
The WordPress admin bar is a handy toolbar that sits on the top of your website allowing logged in users (typically administrators) to click to the WordPress main dashboard or edit the page or post.
Sometimes, you do not want this admin bar to show to certain user roles. For example, you may only want to show it to logged in administrators but not subscribers.
This PHP snippet allows you to quickly remove the WordPress admin bar from the frontend for all user roles including administrators. So it does not matter whether their logged in user role is: Administrator, Editor, Author, Contributor, Subscriber, Shop Manager, or Customer, the admin bar will not show on the frontend.
You can also control where on your site you want this script to run (i.e. places on your site you do not want the admin bar showing). This is controlled via the Placements widget. You can select specific sections such as posts, pages, categories, custom posts and tags, or select common sections such as the entire website frontend, which would be the ideal choice.
Download WP Snippets AI for free
- Click the button below. Upload/activate the zip file via the Plugins section of your WordPress dashboard.
- Supports automatic updates for security and bug fixes. You don’t even need a license key!!
Includes Elementor add-ons • No credit card required • Supports automatic updates
Video explainer for removing WP admin bar for all users
The video below will explain step-by-step how to add the Virtual Crowd script using the WP Snippets AI plugin.
Code snippet for removing WP admin bar for all users
Once you have created a new snippet in WP Snippets AI, copy and paste the code below and click Save.
// Remove the admin bar from the frontend for all user roles including administrators
function remove_admin_bar_style_frontend() { // css override for the frontend
echo '';
}
add_filter('show_admin_bar', '__return_false');
add_filter('wp_footer','remove_admin_bar_style_frontend');