Skip to content

Instantly share code, notes, and snippets.

@adambradford
Last active April 27, 2018 19:09
Show Gist options
  • Save adambradford/1b2f67e801b3b587bcac7f0529aaec82 to your computer and use it in GitHub Desktop.
Save adambradford/1b2f67e801b3b587bcac7f0529aaec82 to your computer and use it in GitHub Desktop.
Hide the WordPress admin bar from Subscribers or any logged in user who can't edit posts
<?php
//* Add this to your functions.php file. Do NOT include the opening php tag
//* Hide the admin bar from anyone who can't edit posts
add_action('set_current_user', 'ab_hide_admin_bar');
function ab_hide_admin_bar() {
if (!current_user_can('edit_posts')) {
show_admin_bar(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment