Code Snippets

Restrict Access to WP Admin to Administrators Only

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;
}
}
view raw functions.php hosted with ❤ by GitHub