Hi again @sicdesign
Our devs came through with a couple of options for you that you can use in either your active theme’s functions.php file, or a mu-plugin (I always prefer mu-plugin for this kind of stuff as it’s theme independent). Both code options still display countries in full text on the front for users. ??
This one changes the country label to the 2-character ISO code throughout for all forms, meaning the country would display as ISO in form submissions, and send as ISO to all integrations. Just need to be sure your address field ID is address-1 or change it in the code:
add_filter( 'forminator_field_create_select', function ( $html, $attr ) {
$field_id = 'address-1';
if ( $attr['name'] === $field_id . '-country' ) {
$html = preg_replace_callback( '/<option value="(.*?)"\s*>(.*?)<\/option>/', function ( $matches ) {
preg_match( '/data-country-code="([^"]*)"/', $matches[0], $codes );
if ( isset( $matches[2] ) && isset( $codes[1] ) ) {
$matches[0] = sprintf( '<option value="%s" data-country-code="%s" >%s</option>', $codes[1], $codes[1], $matches[2] );
}
return $matches[0];
}, $html );
}
return $html;
}, 10, 2 );
This 2nd option is more granular as it can be used only for a specific form ID, and only changes how the country data is sent to Zapier. The country would still display in full in submissions, but Zapier would receive the ISO code that you can use with your Zoom zap there.
Here again, change address-1 if needed to the correct field ID for your form (appears in 2 places in the code below), and change the 697 to the actual ID of your form:
add_filter( 'forminator_addon_formatted_submitted_data', function( $formatted_post_data, $post_data, $files_data, $form_fields ) {
$form_id = filter_input( INPUT_POST, 'form_id', FILTER_VALIDATE_INT );
if ( 697 === $form_id && empty( $formatted_post_data['country_code'] ) && ! empty( $post_data['address-1-country'] ) ) {
$countries = forminator_get_countries_list();
$code = array_search( $post_data['address-1-country'], $countries, true );
if ( $code ) {
$formatted_post_data['country_code'] = $code;
}
}
return $formatted_post_data;
}, 10, 4 );
Please do let us know if either of these work for you, or if you need more help with this.
Cheers!
Patrick