WordPress 4 - Benny

How to Disable WordPress Admin Bar for All Users Except Administrators

0 Shares
0
0
0
0
0
0
0

I am working on a new public domain website http://www.forefingerfirst.com/ where people can only able to vote after FB login. So I have done customized the easy facebook login plugin.

But then we are facing the issue that once user login with FB.

He/She was getting the Admin bar. So I have searched for a solution and below is a step for the same.

Just open function.php from our current theme and add below code

add_action('after_setup_theme', 'remove_admin_bar');
function remove_admin_bar() {
    if (!current_user_can('administrator') && 
      !is_admin()) {
      show_admin_bar(false);
    }
}

Disable Admin Bar for All Users

If you want to disable it for all users, then simply put use this code in your theme’s functions.php file

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