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?

Related posts

Leave a Reply

2 comments

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