Skip to content

Instantly share code, notes, and snippets.

@mustardBees
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mustardBees/8720914 to your computer and use it in GitHub Desktop.
Save mustardBees/8720914 to your computer and use it in GitHub Desktop.
Hook into Gravity Forms after form submission in order to save latitude/longitude in the format expected by the CMB Field Type: Google Maps plugin.
<?php
/**
* Save latitude/longitude for display in a CMB field
*
* @author Phil Wylie
* @link http://link.from.pw/1ejMnDr
*/
function pw_save_latitude_longitude( $entry, $form ) {
$latitude = $entry[3]; // where 3 is the field ID for latitude
$longitude = $entry[4]; // where 4 is the field ID for longitude
$location = array(
'latitude' => $latitude,
'longitude' => $longitude
);
update_post_meta( $entry['post_id'], 'location', $location ); // location is your CMB field ID
}
add_action( 'gform_after_submission_1', 'pw_save_latitude_longitude', 10, 2 ); // where 1 is the form ID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment