Hi!
I want to use my form results in a map so I'm trying to get the user's latitude and longitude pair into the entry.
I created 2 fields, "lat" and "lon", activated the option to dynamically populate and entered the same name in the parameter field ("lat" and "lon" respectively).
I then added the following code to my functions php (omitted code for longitude as it's the same) but my fields are not being populated.
JSON parsing works, field population works (tested static text) but together they don't work.
Does anyone knows why?
add_filter("gform_field_value_lat", "populate_lat");
function populate_lat($value){
$ip = RGFormsModel::get_ip();
$json = file_get_contents('http://freegeoip.appspot.com/json/$ip');
$expression = json_decode($json);
$lat = $expression->latitude;
return $lat;
}
Thanks!
Ricardo