联系人表单7电子邮件模板中的PHP代码 [英] PHP code inside Contact form 7 Email template

查看:81
本文介绍了联系人表单7电子邮件模板中的PHP代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在联系表格7 电子邮件模板中插入PHP代码?我想在其中使页脚版权年度具有动态性。

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.

推荐答案

这可以通过使用 wpcf7_before_send_mail来实现钩子。

在您的functions.php中,您可以使用以下代码:

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 ) );

}

这篇关于联系人表单7电子邮件模板中的PHP代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆