<?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: Saving lat/long data from a form</title>
		<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form</link>
		<description>Gravity Support Forums Topic: Saving lat/long data from a form</description>
		<language>en-US</language>
		<pubDate>Sat, 04 Apr 2026 15:53:21 +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/saving-latlong-data-from-a-form" rel="self" type="application/rss+xml" />

		<item>
			<title>clay123 on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-37637</link>
			<pubDate>Tue, 11 Oct 2011 18:22:46 +0000</pubDate>
			<dc:creator>clay123</dc:creator>
			<guid isPermaLink="false">37637@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Ohhh I see! I'm not using the advanced address field because I'm creating posts from the form using POST CUSTOM FIELD s.. Got it so I just use the number from the input field! Thank yoU!!!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-37621</link>
			<pubDate>Tue, 11 Oct 2011 17:37:43 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">37621@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Clay,&#60;/p&#62;
&#60;p&#62;The 6.x IDs are probably not correct. The address field has an ID (ie 2) and then it has a decimal number for each input in the field, so:&#60;/p&#62;
&#60;p&#62;Address = 2.1&#60;br /&#62;
Address Line #2 = 2.2&#60;br /&#62;
City = 2.3&#60;br /&#62;
State = 2.4&#60;br /&#62;
Zip = 2.5&#60;br /&#62;
Country = 2.6&#60;/p&#62;
&#60;p&#62;Make sense?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>clay123 on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-37600</link>
			<pubDate>Tue, 11 Oct 2011 17:01:47 +0000</pubDate>
			<dc:creator>clay123</dc:creator>
			<guid isPermaLink="false">37600@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;By the way the fields for latitude and longitude are _wp_geo_latitude and _wp_geo_longitude
&#60;/p&#62;</description>
		</item>
		<item>
			<title>clay123 on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-37599</link>
			<pubDate>Tue, 11 Oct 2011 16:57:59 +0000</pubDate>
			<dc:creator>clay123</dc:creator>
			<guid isPermaLink="false">37599@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks for the code help David! That's really kind of you. I updated my address city, state, zip fields and api, but no luck. See anything I did wrong? Note, while I removed it here, I included my gmaps api as well.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://pastie.org/2679206&#34; rel=&#34;nofollow&#34;&#62;http://pastie.org/2679206&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Smith on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-37468</link>
			<pubDate>Mon, 10 Oct 2011 13:08:15 +0000</pubDate>
			<dc:creator>David Smith</dc:creator>
			<guid isPermaLink="false">37468@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Clay,&#60;/p&#62;
&#60;p&#62;There were several issues with the code. I've cleaned it up a bit but you will still need to replace some variables to integrate with your specific form.&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://pastie.org/2672031&#34; rel=&#34;nofollow&#34;&#62;http://pastie.org/2672031&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Also, don't forget to add your API key back in.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>clay123 on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-37325</link>
			<pubDate>Fri, 07 Oct 2011 17:17:08 +0000</pubDate>
			<dc:creator>clay123</dc:creator>
			<guid isPermaLink="false">37325@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I was wondering if I could get a little direction on this. I would like to geocode lat and lng from the address the user provides in the form and insert lat and lng into the database as post meta. I know how to set up the form, but not sure if I'm on the right track for defining a pre submission function calling the data back from google api. Here's what I pieced together so far, not working.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
// gforms hook for form_#
add_action(&#38;quot;gform_pre_submission_6&#38;quot;, &#38;quot;pre_submission&#38;quot;);
function pre_submission_handler($form){

	// 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;
	 }
	}

	//was called process.php
	$query_string = $_POST[&#38;#39;address&#38;#39;] . &#38;quot;+&#38;quot; . $_POST[&#38;#39;city&#38;#39;] . &#38;quot;+&#38;quot; . $_POST[&#38;#39;state&#38;#39;] . &#38;quot;+&#38;quot; . $_POST[&#38;#39;zipcode&#38;#39;];
	$coords = getLatLong($query_string);
	$lat = $coords[&#38;#39;_wp_geo_latitude&#38;#39;];
	$lng = $coords[&#38;#39;_wp_geo_longitude&#38;#39;];
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-16822</link>
			<pubDate>Fri, 21 Jan 2011 21:59:50 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">16822@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;We are finishing up all new documentation that will launch with Gravity Forms v1.5 at the beginning of February.  Until then I have created a PDF of the gform_pre_submission hook example and specifications.&#60;/p&#62;
&#60;p&#62;You can download the PDF here:&#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://bit.ly/i1xedx&#34; rel=&#34;nofollow&#34;&#62;http://bit.ly/i1xedx&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>hardseatsleeper on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-16818</link>
			<pubDate>Fri, 21 Jan 2011 21:30:22 +0000</pubDate>
			<dc:creator>hardseatsleeper</dc:creator>
			<guid isPermaLink="false">16818@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi Carl,&#60;/p&#62;
&#60;p&#62;The Google geocoding I know already, that's not a problem. It's the gform_pre_submission that I don't know. &#60;/p&#62;
&#60;p&#62;&#60;a href=&#34;http://www.gravityhelp.com/?s=gform_pre_submission&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/?s=gform_pre_submission&#60;/a&#62;&#60;/p&#62;
&#60;p&#62;Thanks for the help, let me look into this. If I can jimmy something I'll post back here.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-16813</link>
			<pubDate>Fri, 21 Jan 2011 20:36:02 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">16813@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;This is possible, but it would be fairy complicated.  You would first need to know how to use the Google geocoding API.  &#60;/p&#62;
&#60;p&#62;You would first need to add one or two hidden fields to your form depending on if you want to store the lat/long in one field or as a lat and a long.&#60;/p&#62;
&#60;p&#62;On form submission you would use the gform_pre_submission hook and pass the field data for the Address field to Google geocoding API and receive back a lat/long.  &#60;/p&#62;
&#60;p&#62;You would then also use the gform_pre_submission hook to then store the value that Google returns in the hidden fields.&#60;/p&#62;
&#60;p&#62;You would need to know hot to use WordPress hooks, and the Google geooding API to pull it off.  It is certainly doable.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>hardseatsleeper on "Saving lat/long data from a form"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/saving-latlong-data-from-a-form#post-16810</link>
			<pubDate>Fri, 21 Jan 2011 20:23:32 +0000</pubDate>
			<dc:creator>hardseatsleeper</dc:creator>
			<guid isPermaLink="false">16810@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;This is not a GF issue really, but maybe some of you brainiacs can help me.&#60;/p&#62;
&#60;p&#62;I have a form where people are entering addresses &#38;amp; locations. I could use Google's reverse geocoding APIs to get the latitude and longitude of the adresses, but what I really want to do is save that data to the db when they submit.&#60;/p&#62;
&#60;p&#62;Any idea how I could hack a gravity form to run the geocoder, then save the lat/long to the db?
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
