PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Dynamically populate fields sanity check

  1. rbl

    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('$ip');
    	$expression = json_decode($json);
    	$lat = $expression->latitude;
       return $lat;


    Posted 9 years ago on Sunday May 29, 2011 | Permalink
  2. Hi Ricardo,

    If you change the single quotes to double quotes on this line:

    $json = file_get_contents('$ip'); should be golden. PHP does not parse single quoted lines for variables so the IP is not being passed.

    Posted 9 years ago on Monday May 30, 2011 | Permalink
  3. rbl

    Duh moment! Thanks David! =)


    Posted 9 years ago on Tuesday May 31, 2011 | Permalink