• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Display the country problem?!?

Display the country problem?!? 6 years 11 months ago #36974

  • servlet
  • servlet's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 13
Hello
I follow the instruction "Display the country from which the form is being submitted"

But it doesnt display country in e-mail. I tried with and without slashes //<code>
In this article we will describe how to get the IP address of a submitting client and displaying the country which it belongs to.

In order to achieve this functionality, just create a hidden field with the following code placed in the "Default Value" area.


//<code>
try {
// Let's cache results for better performance
$cache = JFactory::getCache();
$cache->setCaching(true);

// Grab the IP
$ip = JFactory::getApplication()->input->server->getString('REMOTE_ADDR');

// Call function through cache
return $cache->call('rsform_get_ip', $ip);
} catch (Exception $e) {

}

function rsform_get_ip($ip) {
// Get the HTTP transport
$http = JHttpFactory::getHttp();

// Create the URL for the API request
$url = 'freegeoip.net/json/'.urlencode($ip);

// Get response
$response = $http->get($url);

// Check if request is successful, a 200 code should be received.
if ($response->code == 200) {
// Decode response
if ($json = json_decode($response->body)) {
return $json->country_name;
}
}

return 'Unknown';
}
//</code>

Let's say, for example that you named your hidden field "location". To display the calculated value in the "Thank you" page or email just use this syntax: {location:value}.
The administrator has disabled public write access.

Display the country problem?!? 5 years 11 months ago #38265

Hello, i have the same problem to.
Has there anyone an solution.

Thank you
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!