

Learn how to easily hide the WordPress admin bar for all users except administrators. This guide helps you manage user access and optimize your WordPress site.
<?php
add_filter('show_admin_bar',function( $show_admin_bar ) {
if(!current_user_can('manage_options')) {
return false;
}
return $show_admin_bar;
});
Follow these simple steps to hide the admin bar for all users except administrators:
That’s it! The admin bar is now hidden for all non-administrator users on your WordPress site.
WordPress has a built-in user role system that determines what different users can and cannot do on your site. The administrator role has the highest level of permissions, including full control over themes, plugins, users, and settings. Other roles, like editors, authors, contributors, and subscribers, have progressively fewer capabilities.
The WordPress admin bar appears automatically for users with sufficient permissions, providing quick access to backend functions. By default, administrators, editors, authors, and contributors see the admin bar on both the frontend and backend, while subscribers typically only see it in the admin area.
Hiding the admin bar for non-administrator users makes sense for several reasons. For client websites, the admin bar often confuses visitors and can interfere with your site’s design and navigation. It adds visual clutter that serves little purpose for users who don’t need backend access.
On membership sites and multi-author blogs, hiding the admin bar creates a cleaner user experience for regular members while maintaining quick access for content managers. This approach reduces cognitive load and prevents users from accidentally accessing areas they shouldn’t explore.





