Hi Folks,
I have a function that redirects my website visitors in Ireland and the UK to local versions of my website. My problem is the function redirects me too (I’m in Ireland) so I can’t log in to edit my website if I use the function. Can you please help me to exclude a couple of pages such as my WordPress login page?
function country_geo_redirect() {
if ( is_user_logged_in() ) {
return;
}
$country = getenv('HTTP_GEOIP_COUNTRY_CODE');
if ( $country == "GB" ) {
wp_redirect( 'https://www.website.ie', 301 );
exit;
} else if ( $country == "IE" ) {
wp_redirect( 'https://www.website.co.uk', 301 );
exit;
}
}
add_action('init', 'country_geo_redirect');