geoplugin_countryCode != null) { return $data->geoplugin_countryCode; } return null; } $ip_address = get_ip_address(); $country_code = get_country_by_ip($ip_address); if ($country_code !== 'US') { // Redirect to a different page or show an error message header("Location: http://example.com/access-denied.html"); exit; } // Rest of your website code goes here ?>