Display the WordPress admin bar for users with admin privileges only

/**
 * Displays the admin bar for users with admin privileges only.
 *
 * @see https://wpcodebook.com/display-the-wordpress-admin-bar-for-users-with-admin-privileges-only/
 * @see https://developer.wordpress.org/reference/functions/show_admin_bar/
 */
if ( ! current_user_can( 'manage_options' ) ) {
    show_admin_bar( false );
}

Leave a Comment