Skip Navigation

[Gelöst] How to set conditional output based on visitor's country?

This support ticket is created vor 3 Jahre. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 Antworten, has 2 Stimmen.

Last updated by StanleyT8485 vor 3 Jahre.

Assisted by: Christian Cox.

Author
Artikel
#2003435

How do you set a conditional output based on visitor's country? For example, if user is from US, show content "Hello US visitors". If user is from AU, show content "Hello AU visitors", etc.

Stan

#2003745

Hello, I guess it depends on how you expect to determine the User's country. The WordPress platform does not automatically know which country a User is coming from, nor does Toolset have access to this information automatically. That information would have to come from somewhere like a custom field on the User profile, or an IP-based lookup, or the browser's location API, or a custom PHP function.
- Do you have a custom field "country" that holds this information in the profile of each User?
- Or are you expecting to use an IP-based lookup service, or custom PHP function?
- Or do you want to access the User's location from the browser somehow, like during a distance-based Map search?
- Or some other method? Can you explain?

#2003795

Hey Christian,

Thanks for the reply.

No, I don't have any saved information of each user. These users who I am looking to get their country data from are users from Google and are first-time visitors (unregistered, never put their info on our site before).

#2004389

Okay I understand. Toolset does not offer any built-in User location features outside of custom search and distance filters, so you will probably need some custom code to determine that information.

Maybe something like this would be useful:
https://www.geeksforgeeks.org/how-to-get-visitors-country-from-their-ip-in-php/
https://www.geoplugin.com/

These are really outside the scope of Toolset support, so I don't have much information available.

#2004679

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.