2

I have installed WordPress and BudyPress. I want to disable the admin bar which appears on the top for all users.

Can somebody tell me how to do that correctly?

Samvel Aleqsanyan
  • 2,812
  • 4
  • 20
  • 28
sushil bharwani
  • 29,685
  • 30
  • 94
  • 128

3 Answers3

4
function is_current_user_administrator() {
    global $current_user;

    return !in_array( 'administrator', $current_user->roles );
}

add_filter( 'show_admin_bar', 'is_current_user_administrator' );
Johannes Pille
  • 4,073
  • 4
  • 26
  • 27
0

In your functions.php file, you can add one of the following code snippets to get the indicated results:

// Only display to administrators

 add_action('after_setup_theme', 'remove_admin_bar');

 function remove_admin_bar() {
     if (!current_user_can('administrator') && !is_admin()) {
        show_admin_bar(false);
     }
 }
Rahul Shinde
  • 1,522
  • 1
  • 15
  • 17
0

Insert the following code to the end of functions.php file and click Update File Button to save the changes:

add_filter( 'show_admin_bar', '__return_false' );

Jitesh
  • 1