campusboy87
6/21/2018 - 9:20 PM

cf-7 append additional information to mail

cf-7 append additional information to mail

<?php 

add_filter("wpcf7_mail_components", function($components, $curent_cf, $sender ){
    date_default_timezone_set('America/Sao_Paulo');
    $data = date("Y-m-d H:i:s");
    $components['body'] = "Protocolo {$data} \n". $components['body'];
    
    return $components;
},15,3);
<?php 
add_filter('wpcf7_special_mail_tags', function($output, $name, $html) {

    if ('protocol' == $name) {
        date_default_timezone_set('America/Sao_Paulo');
        $data = date("Y-m-d H:i:s");
        return $data;
    }

    return $output;
}, 10, 3);
<?php 
//see https://yadi.sk/i/M5hhJKkU3MkRdN

add_filter("wpcf7_mail_components", function($components, $curent_cf, $sender ){
    date_default_timezone_set('America/Sao_Paulo');
    $data = date("Y-m-d H:i:s");
    

    $components['body'] = str_replace("[protocol]", $data ,  $components['body'] );
    
    return $components;
},15,3);