3

Every time I create a new site under 3.1, my first trip is to the Users > Admin User profile page to uncheck the "admin bar" checkbox.

I'd like to place a script in my theme's functions.php to do this automatically.

Anyone know what that would be?

5

You could use a function inside your theme's functions file to selectively disable it for specific users.

function disable_bar_for_user( $ids ) {

    if( !is_user_logged_in() )
        return;

    global $current_user;

    if( is_numeric( $ids ) )
        $ids = (array) $ids;

    if( !in_array( $current_user->data->ID, $ids ) )
        return;

    add_filter( 'show_admin_bar', '__return_false', 9 );
}

Then call it for the user or users you want to disable the bar for..

Single user:

disable_bar_for_user(1);

Multiple users:

disable_bar_for_user(array(1,2,3));

If you want to just turn it off altogether, then the following should do it(instead of the function).

add_filter( 'show_admin_bar', '__return_false', 9 );

Hope that helps.. :)

| improve this answer | |
3

For functions.php:

// Disable the Admin Bar for All

add_filter( 'show_admin_bar', '__return_false' );
| improve this answer | |
0

I believe you can activate such a plugin sitewide - http://wordpress.org/extend/plugins/disable-admin-bar/

| improve this answer | |
0

Simply set show_admin_bar filter to false in your functions.php.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.