Created
April 5, 2018 15:49
-
-
Save KaineLabs/3872c96902a49ed0ae4e4f320d4fa691 to your computer and use it in GitHub Desktop.
Hide Dashboard Admin Bar For Non Admins.
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
| <?php | |
| /** | |
| * Hide Dashboard Admin Bar For Non Admins. | |
| */ | |
| function yz_hide_dashboard_for_non_admins() { | |
| if ( current_user_can( 'administrator' ) ) { | |
| return false; | |
| } | |
| show_admin_bar( false ); | |
| // Hide Admin Dashboard. | |
| if ( is_admin() && | |
| ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
| wp_redirect( home_url() ); | |
| exit; | |
| } | |
| } | |
| add_action( 'init', 'yz_hide_dashboard_for_non_admins' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment