Created
March 17, 2017 16:51
-
-
Save ingozoell/53ac53cfd654bc224a5a72dd2153d793 to your computer and use it in GitHub Desktop.
Redirect Non Admin User to frontend
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
function redirect_non_admin_user(){ | |
if ( !defined( 'DOING_AJAX' ) && !current_user_can('administrator') ){ | |
wp_redirect( site_url() ); exit; | |
} | |
} | |
add_action( 'admin_init', 'redirect_non_admin_user' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment