Created
January 25, 2018 06:34
-
-
Save trueqap/089c3ec3ca34659da3bc37085e51cd2e to your computer and use it in GitHub Desktop.
Hide admin for NON-ADMIN users WordPress - Redirect non-admin users to home page
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 | |
add_action( 'admin_init', 'redirect_non_admin_users' ); | |
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