/    Sign up×
Community /Pin to ProfileBookmark

How can I edit this redirect function to exclude my wordpress login page?

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?

[code]
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’);
[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@NogDogSep 06.2021 — Welcome to the forums. FYI, I edited your post to wrap the code block in the forum's ... tags, which work much better than the </> control in the edit window does. :(

Anyway, hopefully one of our several JavaScript experts will help you out before too long.
Copy linkTweet thisAlerts:
@BlackrathauthorSep 06.2021 — Thank You NogDog
×

Success!

Help @Blackrath spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.30,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...