skip to Main Content

Good morning, I’m editing Contact Form 7 in wordpress.
I need to change values of this check box [checkbox checkbox-339 use_label_element "Privato" "Azienda"] with "01" for Privati and "02" for Azienda only in automatic mail. How I can do?
Thank

I tried to insert this script in text mail, but no things change…

<span id="cambia">[checkbox-339]</span>

<script>

let text = document.getElementById("cambia").innerHTML; 

curInnerHTML = curInnerHTML.replace("Azienda", "02");

curInnerHTML = curInnerHTML.replace("Privato", "01");

document.body.innerHTML = curInnerHTML;

</script>

I also tried with wpcf7_mail_tag_replaced but I don’t understand much… Where do I insert this string? How do I modify this code to get my goal?

2

Answers


  1. Chosen as BEST ANSWER

    Thank you so much, I resolved more easily with [checkbox* checkbox-339 use_label_element exclusive "Private|01" "Company|02"] . In this way, in front of form appear only "Private" and "Company" while in mail give me only "01" or "02". It's explained well here contactform7.com/selectable-recipient-with-pipes. Best regards


  2. function modify_checkbox_values( $mail ) {
        if ( $mail['id'] == 'your-form-id' ) { // Replace 'your-form-id' with the ID of your Contact Form 7 form
            $new_mail = str_replace( 'Privato', '01', $mail['body'] );
            $new_mail = str_replace( 'Azienda', '02', $new_mail );
            $mail['body'] = $new_mail;
        }
        return $mail;
    }
    add_filter( 'wpcf7_mail_components', 'modify_checkbox_values' );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search