Created
July 28, 2013 18:43
-
-
Save milesstewart88/6099598 to your computer and use it in GitHub Desktop.
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
add_action( 'admin_init', 'redirect_non_admin_users' ); | |
/** | |
* Redirect non-admin users to home page | |
* | |
* This function is attached to the 'admin_init' action hook. | |
*/ | |
function redirect_non_admin_users() { | |
if ( ! current_user_can( 'manage_options' ) && '/wp-admin/admin-ajax.php' != $_SERVER['PHP_SELF'] ) { | |
wp_redirect( home_url() ); | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment