AaronS Posted December 22, 2016 Share Posted December 22, 2016 Hey IPS, What is the best way to grab the location of a forum visitor? This is what we are trying to come up with. So we have products in the Store on our forum. The only payment method to buy these products are via PayPal. Some of these products have recurring charges, so the package gets renewed every 30 days, 90 days, or 180 days. However, if the individual lives in Germany, they have PayPal restrictions that prevent them from purchasing recurring products. So I want to grab the location of the user, if they are in Germany then I want to display a message on the store index stating the PayPal restrictions and to only buy the non-recurring products. What is the best way to accomplish this task? Looking forward to your advice. Thanks in advance. Aaron Link to comment Share on other sites More sharing options...
Solution newbie LAC Posted December 22, 2016 Solution Share Posted December 22, 2016 Hello, try { $geoData = \IPS\GeoLocation::getByIp( \IPS\Member::loggedIn()->ip_address ); if ($geoData['country'] == 'DE') { // Show message } } catch ( \Exception $e ) { } sobrenome 1 Link to comment Share on other sites More sharing options...
AaronS Posted December 22, 2016 Author Share Posted December 22, 2016 7 hours ago, newbie LAC said: Hello, try { $geoData = \IPS\GeoLocation::getByIp( \IPS\Member::loggedIn()->ip_address ); if ($geoData['country'] == 'DE') { // Show message } } catch ( \Exception $e ) { } This does the trick! Thanks for helping out! Link to comment Share on other sites More sharing options...
teraßyte Posted December 22, 2016 Share Posted December 22, 2016 Do note that the IPS Geolocation service works only as long as your license is active. If for whatever reason the license is expired it won't retrieve the geolocation. sobrenome 1 Link to comment Share on other sites More sharing options...
AaronS Posted December 23, 2016 Author Share Posted December 23, 2016 20 hours ago, teraßyte said: Do note that the IPS Geolocation service works only as long as your license is active. If for whatever reason the license is expired it won't retrieve the geolocation. Noted. I will pass this on to my other forum admins. Thanks Link to comment Share on other sites More sharing options...
AaronS Posted December 23, 2016 Author Share Posted December 23, 2016 20 hours ago, teraßyte said: Do note that the IPS Geolocation service works only as long as your license is active. If for whatever reason the license is expired it won't retrieve the geolocation. Noted. I will pass this on to my other forum admins. Thanks Link to comment Share on other sites More sharing options...
sobrenome Posted September 23, 2020 Share Posted September 23, 2020 On 12/22/2016 at 9:03 AM, newbie LAC said: Hello, try { $geoData = \IPS\GeoLocation::getByIp( \IPS\Member::loggedIn()->ip_address ); if ($geoData['country'] == 'DE') { // Show message } } catch ( \Exception $e ) { } Does the built in GeoLocation method return the latitude and longitude by IP? Link to comment Share on other sites More sharing options...
newbie LAC Posted September 23, 2020 Share Posted September 23, 2020 1 hour ago, sobrenome said: Does the built in GeoLocation method return the latitude and longitude by IP? Yes sobrenome 1 Link to comment Share on other sites More sharing options...
sobrenome Posted September 23, 2020 Share Posted September 23, 2020 Nice! How can I retrieve it? Tried $geoData['lat'] and $geoData['long'] but there was no data. Link to comment Share on other sites More sharing options...
sobrenome Posted September 24, 2020 Share Posted September 24, 2020 Link to comment Share on other sites More sharing options...
Recommended Posts