When using merge tags to render values in email notifications and success messages, the Google map field will return an escaped JSON encoded string as a value. If you only need a fragment of the payload – e.g; the address – then you may register a custom merge tag that returns the desired value:
<?php add_filter( 'af/merge_tags/resolve', function ( $output, $tag ) { // Check for the custom merge tag if ( 'google_map_address' != $tag ) { return $output; } // Get value from submission. This will be an escaped JSON string. $value = af_get_field( 'google_map' ); // Remove slashes so it is ready for decoding. $value = wp_unslash( $value ); // Decode JSON to array. $value = json_decode( $value, true ); return $value['address']; }, 10, 2 );
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article