Skip to content

Instantly share code, notes, and snippets.

@stevehenty
Created September 18, 2018 07:19
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 stevehenty/31e2080c59cc04bd348b3e55395b572f to your computer and use it in GitHub Desktop.
Save stevehenty/31e2080c59cc04bd348b3e55395b572f to your computer and use it in GitHub Desktop.
<?php
add_filter( 'gravityflow_entry_webhook_response_mapping', 'zip_postal_response_mapping', 10, 4 );
function zip_postal_response_mapping( $entry, $mapping, $data, $step ) {
//Replace 73 with your step ID when you imported the example form 

if ( $step->get_id() == '73' ) {
if ( is_array( $data['places'] ) ) {
$place = $data['places'][0]; //Replace 3,4,5,6 with the field IDs that you have chosen in the response field mapping section.

switch ( $mapping['value'] ):

case '3':
$field = $place['latitude'];
break;
case '4':
$field = $place['longitude'];
break;
case '5':
$field = $place['place name'];
break;
case '6':
$field = $place['state'];
break;
endswitch;
$entry[ $mapping['value'] ] = $field;
}
}
return $entry;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment