• I have a problem with Contact form on wordpress. I would send the email only if a specific input field is selected.

    I wrote this function:

    add_action( 'wpcf7_before_send_mail', "wpcf7_disablEmailAndRedirect" );
    
    function wpcf7_disablEmailAndRedirect( $cf7 ) {
        // get the contact form object
        $wpcf7 = WPCF7_ContactForm::get_current();
    
        // redirect after the form has been submitted
        $wpcf7->set_properties( array(
            'additional_settings' => "on_sent_ok: \"var Iso = $('input[name=radio-814]:checked').val() ; if(Iso == 'value1' ){ location = 'https://www.paypal.com/'; } if(Iso == 'value2' ){ location = 'https://test.it/acquista';}\"",
        ) );
    }

    but the email starts, I want to avoid sending email if input with value “value1” is selected. If I select “value2” the email must start.

    How can I do? Thanks

    https://www.ads-software.com/plugins/contact-form-7/

Viewing 1 replies (of 1 total)
  • I am looking for a similar solution in regards to an “opt-out” selection.

    I have a registration form with an “opt-out” option which is supposed to prevent any ongoing communications between the user and the website. Within the website, after the user registers – there is a “referral” form that the user can fill out to refer someone else to the website.

    Im looking for a solution that says:

    If the registered user is logged in and has selected the “opt-out” option, then do not send the email upon submit – but if the logged in user has not selected the “opt-out” option, then send the conformation email upon submit.

    I am also using Contact Form 7 for the referral form, if that makes a difference?

    Thanks in advance ??

Viewing 1 replies (of 1 total)
  • The topic ‘Disable email if input value is selected’ is closed to new replies.