Skip to content

Instantly share code, notes, and snippets.

@andxbes
Last active July 25, 2019 08:56
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andxbes/cb29eb2cb7af1392fb461c0dffed76a5 to your computer and use it in GitHub Desktop.
Save andxbes/cb29eb2cb7af1392fb461c0dffed76a5 to your computer and use it in GitHub Desktop.
cf-7 append additional information to mail
<?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);
<?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
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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment