December 7, 2017
How to disable wordpress admin bar from front end
Recently we have built a social community site in wordpress and we have to create different levels of users according to their membership.So, we dont want to allow users to access admin panel and display admin bar according to their accees level.Here, we will show you how to achieve it.
Disable wordpress admin bar for all users
There are different ways to achieve it.Just put the below code snippet in your theme’s functions.php
PHP
1 2 3 |
/* Disable WordPress Admin Bar */ show_admin_bar(false); |
Alternately, you can use show_admin_bar filters:
PHP
1 2 |
/* disable the admin bar */ add_filter('show_admin_bar', '__return_false'); |
Another option, just add the below CSS code in your theme’s style.css:
1 2 |
/* disable admin bar */ #wpadminbar { display:none; } |
Disable WordPress Admin Bar for All Users Except for Administrators
PHP
1 2 3 4 5 6 7 8 9 |
/* show admin bar only for admins */ add_action('after_setup_theme', 'tcl_remove_admin_bar'); function tcl_remove_admin_bar() { if (!current_user_can('administrator') && !is_admin()) { show_admin_bar(false); } } |
Disable and Customize the WordPress Admin Bar using Plugins
Also, you can use below mentioned plugins for same.
Hide Admin Bar
Admin Bar Disabler
Auto Hide Admin Bar
Hide Admin Bar from Non-Admins
Remove Admin Bar
Hide Admin Bar From Front End
Related Posts

How to hide Contact Form 7 after successful send

Move new commented activity stream to top
