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; | |
} | |
} |