As you know whenever an user login to WordPress system, who-ever it may be admin or just a subscriber, WordPress automatically shows an admin bar at top of the screen. If the user is administrator then this admin bar provides some useful functionality such as links to navigate to various admin panels of websites, moderating comments, shows available updates etc. The options may be vary depending upon the plugins you have installed.
You might know that this admin bar can be hidden form
Profile > Toolbar > Uncheck “Show Toolbar when viewing site”. This is something depends on user’s will. If they like that admin bar they will not hide it.
But it may happen that, you want to hide admin bar for all users maybe due to it interferes with your design. Both methods below are still valid in current WordPress: the
show_admin_bar filter hides the bar sitewide for every user, while the
show_admin_bar_front user meta lets you hide it for a specific user only.
Option 1: Hide for all users (sitewide)
Add this to your theme’s
functions.php or a site-specific plugin:
add_filter( 'show_admin_bar', '__return_false' );
Option 2: Hide for the current user only
Call this once (e.g. on a settings save or a one-time migration) to set the preference for the currently logged-in user:
// Hide admin bar for the current user only
update_user_meta( get_current_user_id(), 'show_admin_bar_front', false );
Now the admin bar will be hidden from all users (Option 1) or just the chosen user (Option 2). That’s all. Thank you WordPress hooks!