Disable the Admin Bar for Non-Admins

Problem/Use Case:

The top admin bar clutters the frontend for subscribers and other roles.

Snippet:

// Disable admin bar for non-admins
if (!current_user_can('administrator')) {
    add_filter('show_admin_bar', '__return_false');
}

Explanation: Shows the admin bar only for administrators.

Where to Place It: In functions.php.

Bonus Tip: You can extend this to hide the bar for specific roles only.

Ndifon Luke
Ndifon Luke

Ndifon Luke is the founder & owner of Uncle Luke Digitals—a web design, digital marketing freelancer based in Bamenda, Cameroon. He has over 6 years of expertise in digital marketing and is very passionate about working with clients in achieving their business objectives.