Using Zapier to send submissions to our booking software, but running into an issue with phone number formatting, like in this thread: Remove parentheses, space, and dash from phone numbers [RESOLVED]
Basically, our booking software only allows for numbers in International format (+19999999999), and will reject the submission if it includes dashes, parentheses, etc. So I am looking for a way to strip punctuation from phone number data before sending.
I modified the code from the thread mentioned above, but it doesn’t seem to be working. Here’s what I have in my functions.php:
add_filter( 'gform_zapier_field_value', 'gform_truncate_phone_numbers', 10, 4 );
function gform_truncate_phone_numbers( $value, $form, $entry, $field_id ) {
$field = GFAPI::get_field( $form, $field_id );
if ( is_object( $field ) && ( $field->type == 'phone' ) ) {
$value = preg_replace('/[^0-9]/', '', $value);
}
return $value;
}