Ranjit
Ranjit

Reputation: 1724

Disable the admin bar for specific user

I have a WordPress site. There are many users. I want when an author logs in, the author who currently is currently logged on couldn't access the "edit page" menu in the admin bar.

Is there any plugin to disable that?

Upvotes: 1

Views: 707

Answers (2)

Rahul Shinde
Rahul Shinde

Reputation: 1662

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);
    }
}

// Disable for specific role (in this case, 'subscriber')

function remove_admin_bar() {
    $user = wp_get_current_user();

    if (in_array(‘subscriber’, $user->roles)) {
        show_admin_bar(false);
    }
}

Upvotes: 1

Rahul
Rahul

Reputation: 5774

You can use this plugin :

http://wordpress.org/extend/plugins/admin-bar-disabler/

OR Alternative and manual way is under if condition place this

show_admin_bar(false);

E.g.

if(!is_admin())
{
    show_admin_bar(false);
}

place this code in functions.php so that it will disable the admin bar for all the other users.

Upvotes: 1

Related Questions