Forums

Translating IP Address before sending email

oriald 06 Aug, 2010
Hi Guys,

Currently, when we get email notification about a submission by the form we see at the bottom "Submitted by xxx.xxx.xxx.xxx"

We need to translate it using an API to actual city/country.

We already have the code from the API site:
$tags = get_meta_tags('http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=189.222.9.192');
print $tags['city']; // city name

How/where do we incorporate this so it will be translated PRIOR to sending the email. we want the email to contain the City/Country value instead/alongside the IP.

Any help would be MUCH appreciated.

Ori๐Ÿ™‚
GreyHead 07 Aug, 2010
Hi Ori,

You'll need to turn off 'Include IP Address' in the Email Setup Properties box, then put something like this in the OnSubmit Before Box.
<?php
$ipaddress = $_SERVER['REMOTE_ADDR'];
if ( $ipaddress ) {
  $tags = get_meta_tags('http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=189.222.9.192');
  $ipaddress = $ipaddress.' : '.$tags['city'].' / '.$tags['country'];
} else { 
  $ipaddress = 'Not found';
}
JRequest::setVar(ipaddress2, $ipaddress);
?>
and then use {ipaddress2} in your Email Template

Bob
oriald 11 Aug, 2010
You da man!!!๐Ÿ™‚

THANKS! (works)
This topic is locked and no more replies can be posted.