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