Contact-form-7:动态更改自动回复中的年文本 [英] Contact-form-7: Change year-text in auto-replies dynamically

查看:78
本文介绍了Contact-form-7:动态更改自动回复中的年文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在每封自动回复的电子邮件中,都有用于版权目的的文本,例如:< em>版权所有©2019-保留所有权利.</em>

In every email auto-reply, there is a text for copyright purposes like: <em>Copyright © 2019 - All rights reserved.</em>

每年我都必须为每种表格手动更改它.

Every year I have to change it manually for every form.

这可以自动完成吗?

像用变量替换年份:< em>版权©{{current_year}}-保留所有权利.</em> ?

推荐答案

CF7电子邮件中没有简单的变量替换".但是,很容易包括表单字段的值.这样,您就可以创建一个自定义表单标签 [year_tag] 您可以将其包含在联系表单的表单"标签中.(可能就在[submit]标​​签之前.)

There is no simple 'variable replacement' in the CF7 email. It is however easy to include the value of a form field. With that said, you could create a custom form tag [year_tag] which you would include on the "FORM" tab of your contact form. (It could be right before the [submit] tag.)

首先,您可以将以下代码添加到主题functions.php中,并且/或者如果愿意的话,可以将其放在插件中.

First, you would add the below code to your theme functions.php and/or you could put it in a plugin if you were so inclined.

function dd_add_year_tag(){
        // This adds a form tag to the FORM itself called [year_tag]
        wpcf7_add_form_tag('year_tag', 'cf7_year_field_handler');
}
add_action('wpcf7_init', 'dd_add_year_tag');

function cf7_year_field_handler($tag){
    $year = date('Y');
    // create hidden form field with name "current-year" and Current Year as value.
    $output = '<input type="hidden" name="current-year" value='.$year.'>';
    return $output;
}

然后在您的电子邮件中放入

Then on your email you would put.

<em>Copyright © [current-year] - All rights reserved.</em>

-在CF7电子邮件表单上...表单字段的名称可用于输出任何隐藏或可见的表单字段.

-- On the CF7 E-Mail form... the NAME of the form field can be used to output any form field, whether hidden or visible.

这篇关于Contact-form-7:动态更改自动回复中的年文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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