Last active
April 27, 2018 19:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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