Ok I see, I went ahead and changed the custom fields to be single line text.
I am not good with coding at all; would you have an example of the code I should use with the 2 custom fields I have. If the example also can be formatted to be an Array so that I can add more than 1 form for this to apply to if it is PHP coding.
Can you please share problem URL where you added your form as well as admin access details.
In addition to that please share one example how exactly you want to store your phone number.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
I've added the following hook "cred_before_save_data" to "Custom Code" section with code snippet "Toolset custom Code":
=> hidden link
add_action('cred_before_save_data', 'func_adjust_phone_fax_values',10,1);
function func_adjust_phone_fax_values($form_data){
// if a specific form
if ($form_data['id']==69241) {
if (isset($_POST['wpcf-phone-number']) and !empty($_POST['wpcf-phone-number'])){
$parts = str_split($_POST['wpcf-phone-number'], 3);
$formatted_number = $parts[0] .'-'. $parts[1] .'-'. $parts[2].$parts[3];
$_POST['wpcf-phone-number'] = $formatted_number;
}
}
}
Now, once you save the form the number will be saved in your desired format.
The code worked well but I have 1 error on line 16. So I looked at some other examples I had on the array format. I made some changes and the following code works well:
add_action('cred_before_save_data', 'func_adjust_phone_fax_values',10,1);
function func_adjust_phone_fax_values($form_data){
$form_ids = array(83341,83366); // add more form IDs here
if ( in_array($form_data['id'], $form_ids)) { // Edit as required
if (isset($_POST['wpcf-user-contact-phone']) and !empty($_POST['wpcf-user-contact-phone'])){
$parts = str_split($_POST['wpcf-user-contact-phone'], 3);
$formatted_number = $parts[0] .'-'. $parts[1] .'-'. $parts[2].$parts[3];
$_POST['wpcf-user-contact-phone'] = $formatted_number;
}
if (isset($_POST['wpcf-user-contact-fax']) and !empty($_POST['wpcf-user-contact-fax'])){
$parts = str_split($_POST['wpcf-user-contact-fax'], 3);
$formatted_number = $parts[0] .'-'. $parts[1] .'-'. $parts[2].$parts[3];
$_POST['wpcf-user-contact-fax'] = $formatted_number;