US based redirect resulting in 500 error
-
Hi guys,
I’m trying to get a redirect to work which redirects all visitors from the US to a specific page. But everytime I enable the function the site throws a generic 500 error.The code in question is:
function country_geo_redirect() { $country = null; if ( class_exists( 'WPEngine\GeoIp' ) ) { ??$geo = WPEngine\GeoIp::instance(); ??$country = $geo->country(); } if ( $country == "US" ) { wp_redirect( 'https://domain.com/us', 301 ); exit; } } add_action('init', __NAMESPACE__ . '\\country_geo_redirect');
The namespacing in the add_action bit is because I’m using the Sage starter theme. Any ideas of whats going on?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘US based redirect resulting in 500 error’ is closed to new replies.