Forked from VanLuda/Block Non-Admins from Accessing Dashboard
Created
July 8, 2019 13:06
-
-
Save pije76/dd1f277ea0c3e5dbc1b5aa89f5f73d8e 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