add_action( 'admin_init', '_admin_redirects' ); function _admin_redirects() { if ( !is_user_logged_in() && $_SERVER['PHP_SELF'] != '/wp-admin/admin-ajax.php' ) { wp_redirect( '/account/' ); exit; } }