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
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?
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).
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.
My issue is resolved now. Thank you!