<?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: Geocode Address on Form Submit</title>
		<link>https://legacy.forums.gravityhelp.com/topic/geocode-address-on-form-submit</link>
		<description>Gravity Support Forums Topic: Geocode Address on Form Submit</description>
		<language>en-US</language>
		<pubDate>Tue, 07 Apr 2026 03:18:11 +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/geocode-address-on-form-submit" rel="self" type="application/rss+xml" />

		<item>
			<title>David Smith on "Geocode Address on Form Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/geocode-address-on-form-submit#post-49156</link>
			<pubDate>Sat, 11 Feb 2012 15:19:39 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">49156@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi nufantech,&#60;/p&#62;
&#60;p&#62;Hm, there may be an issue with where you are adding the hook/filter. Also, are you using an older version of Gravity Forms? The gform_after_submission hook is a relatively newer hook.&#60;/p&#62;
&#60;p&#62;Glad you were able to find an alternate solution. :)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>nufantech on "Geocode Address on Form Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/geocode-address-on-form-submit#post-49155</link>
			<pubDate>Sat, 11 Feb 2012 14:44:06 +0000</pubDate>
			<dc:creator>nufantech</dc:creator>
			<guid isPermaLink="false">49155@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;For whatever the reason, the filter/action is being ignored by GF.  I ended up doing the geocoding directly to the database after the records are added.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Geocode Address on Form Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/geocode-address-on-form-submit#post-49100</link>
			<pubDate>Fri, 10 Feb 2012 22:00:34 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">49100@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Nufantech,&#60;/p&#62;
&#60;p&#62;I didn't see anything obviously wrong with your code. You might try doing some value-checking to make sure the different values are being pulled correctly. Here is an example of how to output the values to the screen:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
print_r($entry);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;And would probably be a good idea to print_r() the $coords after they have been retrieved as well:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;[php]
print_r($coords);&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>nufantech on "Geocode Address on Form Submit"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/geocode-address-on-form-submit#post-48349</link>
			<pubDate>Sat, 04 Feb 2012 14:41:52 +0000</pubDate>
			<dc:creator>nufantech</dc:creator>
			<guid isPermaLink="false">48349@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;There was a post regarding this topic here: &#60;a href=&#34;http://www.gravityhelp.com/forums/topic/saving-latlong-data-from-a-form&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/saving-latlong-data-from-a-form&#60;/a&#62;, but it has been closed.&#60;/p&#62;
&#60;p&#62;Any idea what's wrong with this code?  The values are being pulled from two custom fields, not a Gravity Forms address field.  The fields are ' input_10' and 'input_11'.  I've tried using just the numbers as well as the preceding 'input_' to no avail.&#60;/p&#62;
&#60;p&#62;The custom fields are 'latitude' and 'longitude'&#60;/p&#62;
&#60;p&#62;Any help is appreciated.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;// Geocode New Development Additions
add_action(&#38;quot;gform_after_submission_2&#38;quot;, &#38;quot;pre_submission_handler&#38;quot;);
function pre_submission_handler($entry){

    // update the &#38;quot;1.x&#38;quot; to the ID of your address field
    $query_string = $entry[&#38;#39;10&#38;#39;] . &#38;quot;+&#38;quot; . $entry[&#38;#39;11&#38;#39;];
    $coords = getLatLong($query_string);

    update_post_meta($entry[&#38;#39;post_id&#38;#39;], &#38;#39;lat&#38;#39;, $coords[&#38;#39;latitude&#38;#39;]);
    update_post_meta($entry[&#38;#39;post_id&#38;#39;], &#38;#39;long&#38;#39;, $coords[&#38;#39;longitude&#38;#39;]);

}

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

    $mapsApiKey = &#38;#39;&#38;lt;removed&#38;gt;&#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;</description>
		</item>

	</channel>
</rss>
