I have a client that uses a phone system that supports matching phone numbers that are stored in a custom field in ActiveCampaign with callers. The hitch is that it requires the numbers to be stored without formatting. Is there any way that I can remove the parentheses, space, and dash from phone numbers before processing the entry? I tried the following code, but it seems to reformat the data after the trigger is called:
add_action( ‘gform_pre_submission’, ‘gform_compress_phone_numbers’, 10, 1 );
function gform_compress_phone_numbers( form ) { GFCommon::log_debug( __METHOD__ . '(): ORIGINAL POST' . print_r( POST, true ) );
foreach ( $form[‘fields’] as $field ) {
if ( $field[‘type’] == ‘phone’ ) {
GFCommon::log_debug( METHOD . ‘(): I found a phone number field!’ . print_r( $field, true ) );
$field = 'input’ . $field[‘id’];
$org_value = rgpost ( $field );
GFCommon::log_debug( METHOD . “(): Original value => {org_value}." ); _POST[”{$field}"] = preg_replace(’/[^0-9]/’, ‘’, org_value); GFCommon::log_debug( __METHOD__ . '(): Altered POST' . print_r( _POST, true ) );
}
}
}