Created
October 1, 2016 12:52
-
-
Save VanLuda/e99158a3c23578b69aa78c13d16780aa to your computer and use it in GitHub Desktop.
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
// Block Non-Admins from Accessing Dashboard | |
function blockusers_init() { | |
if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
wp_redirect( home_url() ); | |
exit; | |
} | |
} | |
add_action( 'init', 'blockusers_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment