Created
February 17, 2013 14:33
-
-
Save WebEndevSnippets/4971725 to your computer and use it in GitHub Desktop.
WordPress: Restrict Access to WP Admin to Administrators Only
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', 'webendev_restrict_admin_with_redirect', 1 ); | |
/** | |
* Restrict Access to WP Admin to Administrators Only | |
* | |
*/ | |
function webendev_restrict_admin_with_redirect() { | |
if ( ! current_user_can( 'manage_options' ) && $_SERVER['PHP_SELF'] != '/wp-admin/admin-ajax.php' ) { | |
wp_redirect( site_url() ); exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment