Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
AaronS Posted December 22, 2016 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
Solution newbie LAC Posted December 22, 2016 Solution 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
AaronS Posted December 22, 2016 Author 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!
teraßyte Posted December 22, 2016 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
AaronS Posted December 23, 2016 Author 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
AaronS Posted December 23, 2016 Author 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
sobrenome Posted September 23, 2020 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?
newbie LAC Posted September 23, 2020 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
sobrenome Posted September 23, 2020 Posted September 23, 2020 Nice! How can I retrieve it? Tried $geoData['lat'] and $geoData['long'] but there was no data.
Recommended Posts