• Resolved joxixi

    (@joxixi)


    Hi,

    I wonder if it’s possible to disable html template for one of the two emails that CF7 can send.

    I have a template for Mail 2 that i use as autorespond, but i don’t want it to apply on the mail i send containing the form data…

    Thanks ??

    btw, great plugin, simple and useful !

Viewing 1 replies (of 1 total)
  • Plugin Author Mário Valney

    (@mariovalney)

    Hi! Thanks for using our plugin and sorry for the late answer.

    We filter the compose method from WPCF7_Mail with “wpcf7_mail_components”. It’s used by WPCF7_Mail::send() and it is used by WPCF7_Submission->mail().

    So we can filter the value before and after this to recreate the old template.
    It’s not beautiful and I was not able to test but it’s a solution using filters and should work.

    <?php
    
    add_filter( 'wpcf7_mail_components', 'joxixi_wpcf7_mail_components_before_cf7het', 9, 3 );
    add_filter( 'wpcf7_mail_components', 'joxixi_wpcf7_mail_components_after_cf7het', 99, 3 );
    
    function joxixi_wpcf7_mail_components_before_cf7het( $components, $contactform, $wpcf7_mail ) {
        if ( $wpcf7_mail->name() != 'mail_2' ) {
            return $components;
        }
    
        $components['body_old'] = $components['body'];
        return $components;
    }
    
    function joxixi_wpcf7_mail_components_after_cf7het( $components, $contactform, $wpcf7_mail ) {
        if ( empty( $components['body_old'] ) ) {
            return $components;
        }
    
        $components['body'] = $components['body_old'];
        unset( $components['body_old'] );
    
        return $components;
    }

    You can put this code in your functions.php or in a new plugin.
    Please backup before try.

Viewing 1 replies (of 1 total)
  • The topic ‘Disable template for Mail 1 or 2’ is closed to new replies.