• Hello,

    I have tried using the Contact Form 7 (with Conditional Fields plugin) to add a conditional email recipient to my form. However, the [if] shortcode doesn’t seem to be recognized by the plugin. I have installed and activated the Contact Form 7 Dynamic Text Extension, as well as the Contact Form 7 Conditional Fields plugin, but the [if] shortcode still doesn’t work.

    I want an email to be sent (in addition to the 2 basic emails already sent) to a mailbox if a checkbox is checked.

    I have searched for a solution and tried different methods, but unfortunately, I have not been able to resolve the issue.

    Could you please provide me with further guidance or a solution on how to make this work? Thank you in advance for your assistance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hello,
    it seems that the task you indicate should be implemented as a filter wpcf7_mail_components.

    PS.
    https://wordpress.stackexchange.com/q/367934
    https://wp-plugin-api.com/hook/wpcf7_mail_components/

    Thread Starter ltdansdis

    (@ltdansdis)

    Thank you for your answer,

    Unfortunately, I don’t think that this function exactly meets my needs.

    I would like that if the user checks the “Fill” box it sends an email to a specific recipient with the information from the said form.

    I hope to be more precise

    Thanks in advance

    @ltdansdis,
    as the title says, I understand that it is about additional mail, i.e. conditional sending of the “Mail (2)” template. If we understand each other correctly, it should be something like this:

    add_filter( 'wpcf7_mail_components', 'custom_mail_components', 10, 3 );
    
    function custom_mail_components( $components, $contact_form, $mail ) {
    
        if ( 'mail_2' !== $mail->name(); ) {
            return $components;
        }
    
        $components['active'] = false;
    
        $submission = WPCF7_Submission::get_instance();
        if ( is_null( $submission ) ) {
            return $components;
        }
    
        $tag_name = 'your-checkbox';
    
        $posted_data = $submission->get_posted_data();
        if ( is_null( $posted_data ) || ! isset( $posted_data[ $tag_name ] ) {
            return $components;
        }
    
        $components['active'] = (bool) $posted_data[ $tag_name ];
        return $components;
    
    }

    If this is the third email, it will probably help to use the wpcf7_additional_mail filter.

    • This reply was modified 1 year, 11 months ago by AW.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Extra email with an “if” condition’ is closed to new replies.