<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: updating hidden fields using gform_after_submission hook - geocoding</title>
		<link>https://legacy.forums.gravityhelp.com/topic/updating-hidden-fields-using-gform_after_submission-hook-geocoding</link>
		<description>Gravity Support Forums Topic: updating hidden fields using gform_after_submission hook - geocoding</description>
		<language>en-US</language>
		<pubDate>Thu, 23 Apr 2026 16:18:57 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/updating-hidden-fields-using-gform_after_submission-hook-geocoding" rel="self" type="application/rss+xml" />

		<item>
			<title>studioleland on "updating hidden fields using gform_after_submission hook - geocoding"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/updating-hidden-fields-using-gform_after_submission-hook-geocoding#post-63207</link>
			<pubDate>Thu, 21 Jun 2012 14:52:01 +0000</pubDate>
			<dc:creator>studioleland</dc:creator>
			<guid isPermaLink="false">63207@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hey guys,&#60;/p&#62;
&#60;p&#62;I have been reading this:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.gravityhelp.com/forums/topic/editing-updating-field-value-after-submission&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/editing-updating-field-value-after-submission&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;and want to use for the following geocoding on the fly after submission:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;// gforms hook for form_#
add_action(&#38;quot;gform_after_submission_2&#38;quot;, &#38;quot;pre_submission_handler&#38;quot;);
function pre_submission_handler($entry){

    // pass the entries relating to the address parts from form
    $query_string = $entry[&#38;#39;21&#38;#39;] . &#38;quot;+&#38;quot; . $entry[&#38;#39;22&#38;#39;] . &#38;quot;+&#38;quot; . $entry[&#38;#39;23&#38;#39;];
    $coords = getLatLong($query_string);

    update_post_meta($entry[&#38;#39;post_id&#38;#39;], &#38;#39;lat&#38;#39;, $coords[&#38;#39;_wp_geo_latitude&#38;#39;]);
    update_post_meta($entry[&#38;#39;post_id&#38;#39;], &#38;#39;lng&#38;#39;, $coords[&#38;#39;_wp_geo_longitude&#38;#39;]);

}

// function to take address and turn it into coordinates lat and lng
function getLatLong($code){

    $mapsApiKey = &#38;#39;(REMOVED FROM POST ONLY)&#38;#39;;
    $query = &#38;quot;http://maps.google.com/maps/geo?q=&#38;quot;.urlencode($code).&#38;quot;&#38;amp;output=json&#38;amp;key=&#38;quot;.$mapsApiKey;

    // This takes your full street address to create the lat/long
    $data = file_get_contents($query);

    // if data returned
    if($data){
        // convert into readable format
        $data = json_decode($data);
        $long = $data-&#38;gt;Placemark[0]-&#38;gt;Point-&#38;gt;coordinates[0];
        $lat = $data-&#38;gt;Placemark[0]-&#38;gt;Point-&#38;gt;coordinates[1];
        return array(&#38;#39;Latitude&#38;#39;=&#38;gt;$lat,&#38;#39;Longitude&#38;#39;=&#38;gt;$long);
    } else {
        return false;
    }
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Except all I need to do is save the geocoded coordinates in 2 hidden gform fields in same form for output later.  I believe this example is for saving to post meta instead of the form entry.  Any help appreciated thanks.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
