Created
August 30, 2017 22:14
-
-
Save strangerstudios/f7be8cf6dea1ed8a9f08ba83f5c6f043 to your computer and use it in GitHub Desktop.
Disable the admin bar for any user who is not admin, can't edit users and can't edit posts.
This file contains hidden or 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
/* | |
Disable the admin bar for any user who is not admin, | |
can't edit users and can't edit posts. | |
Add this code to a custom plugin. | |
*/ | |
function my_custom_disable_admin_bar() { | |
if(!current_user_can('administrator') && !current_user_can('edit_users') && !current_user_can('edit_posts')) { | |
add_filter( 'show_admin_bar', '__return_false' ); | |
add_action( 'admin_print_scripts-profile.php', 'habfna_hide_admin_bar_settings' ); | |
} | |
} | |
add_action('init', 'my_custom_disable_admin_bar', 9); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment