WP Munk > Blog > Code Snippets > How to Hide Admin Bar for Logged in Users

How to Hide Admin Bar for Logged in Users

If you have a WordPress site where end users have to login and you do not want to show the Admin bar to those users then you can disable the Admin bar globally for all users by adding following line of code into your theme’s functions.php file.

//Disable WordPress Admin Bar for all users. */
show_admin_bar(false);

If you want to disable the Admin Bar for end user but still want to show it for Administrator then use following code:

//Disable WordPress Admin Bar for all users except admins */
function wphelp_remove_adminbar() {
if (!current_user_can('administrator') && !is_admin()) {
  show_admin_bar(false);
}
}
add_action('after_setup_theme', 'wphelp_remove_adminbar');

About The Author


Mohammad Tajim

Hello, I am Mohammad Tajim a WordPress Developer with over 14 years of experience building WP Products. I made Munk WordPress Theme and other themes available at metricthemes.com. Follow me on twitter @tajim

More free templates for download at: Google Slides Themes

Copyright © 2020 WP Munk.
Built with Munk and Powered by WordPress.