-
-
Save stevehenty/31e2080c59cc04bd348b3e55395b572f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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