add_action('template_redirect', 'redirect_non_logged_in_users'); function redirect_non_logged_in_users() { // Check if the user is not logged in and is not accessing wp-login.php or wp-admin if (!is_user_logged_in() && !is_page('wp-login.php') && !is_admin()) { // Redirect to the specified external URL wp_redirect('https://omniform1.com/forms/v1/landingPage/67f6c3b2f8deedeb6f9cd336/67f6c8a7f8fbc713dd3172fc'); exit; } }