Is there any way to insert PHP code inside contact form 7
Email Template? I want to make footer copyright year as dynamic in it.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This is possible by using the wpcf7_before_send_mail
hook.
In your functions.php you can use the following code:
add_action( 'wpcf7_before_send_mail', 'wpcf7_add_text_to_mail_body' );
function wpcf7_add_text_to_mail_body($contact_form){
// get mail property
$mail = $contact_form->prop( 'mail' ); // returns array with mail values
// add date (or other content) to email body
$mail['body'] .= date('Y');
// set mail property with changed value(s)
$contact_form->set_properties( array( 'mail' => $mail ) );
}