• Resolved jaegerms

    (@jaegerms)


    Hello,

    I want that cf7 sends an email to the person who filled out the contact form when he ticks the box that he wants to receive the booklet. If he doesn’t tick the box, he should not receive the email with the booklet.

    Can anyone help me how I can do this?

    Thanks in advance!

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi,
    You can instal conditional fields plugin and add conditional if field want bokled equals your-e-mail add hide fields your-email and add this fields in e-mail2 to fields.

    Regards
    Mateusz

    Hi @jaegerms

    I am wondering if you have found a way to do it without hiding the email field with conditional fields plugin? My website functionality is exactly the same as yours. I would like user to be able to choose whether to receive a booklet or not.

    Would you be able to share your solution?
    Thx

    Thread Starter jaegerms

    (@jaegerms)

    Hi @andrewhw

    I solved the problem without the plugin. It’s not the ideal solution but it is like everyone gets a message if they fill out the form. But only the ones that checked the box with the booklet will get the link to the booklet. This can be done with the second email in cf7 by checking the box “Exclude lines with empty email tags from output”.

    I hope this helps.

    Hi @jaegerms

    Thx for the reply. I managed to solve the problem without the plugin and adding a function to the plugin. I will just leave it here in case someone else need it in the future.

    function check_mail_send_contactform($cf7) {
    $submission = WPCF7_Submission::get_instance();
    if ( $submission ) {
    $posted_data = $submission->get_posted_data();
    }
    $mail = $cf7->prop( ‘mail’ );

    if($posted_data[‘newsletter’][0]) {
    $mail2 = $cf7->prop( ‘mail_2’ );
    $mail2[‘recipient’] = $posted_data[‘your-email’];
    $cf7->set_properties( array( ‘mail_2’ => $mail2 ) );
    }
    return $cf7;
    }
    add_action(‘wpcf7_before_send_mail’,’check_mail_send_contactform’);

    Cheers

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘cf7 conditional email with checkbox’ is closed to new replies.