lenden
lenden

Reputation: 830

How to disable admin bar in wordpress 3.9?

I'm trying to disable admin bar for registered users, whiche are not administrators. I found many solutions like adding

if ( ! current_user_can( 'add_users' ) ) {
show_admin_bar( false ); }

to functions.php, but it totally doesn't work. As I understand it is problem of "the best" version 3.9. I also tried many plugins - there are no working ones... Does any solution exist today?

Upvotes: 0

Views: 1166

Answers (3)

MADPT
MADPT

Reputation: 97

Go to Users > Admin Profile > Toolbar > Deselect "Show Toolbar when viewing site"

Upvotes: 0

Bangash
Bangash

Reputation: 1172

including this line of code in functions.php will disable it altogether,

add_filter( 'show_admin_bar', '__return_false');

Edit: The accepted answer is better than my answer, because that method doesn't disable the admin bar altogether, but it disables it based on the user permissions.

Upvotes: 1

Nathan Dawson
Nathan Dawson

Reputation: 19308

Have you tried using the filter? Add this to your functions.php replacing your existing code:

function wpse_hide_admin_bar() {
    if ( current_user_can( 'manage_settings' ) ) {
        return true; // Show for admins
    } else {
        return false; // Hide for other users
    }
}
add_filter( 'show_admin_bar', 'wpse_hide_admin_bar' );

Upvotes: 1

Related Questions