【问题标题】:How to pass the custom value in contact form 7 message body on WordPress?如何在 WordPress 的联系表单 7 消息正文中传递自定义值?
【发布时间】:2022-01-04 08:10:54
【问题描述】:

我正在尝试在下拉菜单中显示额外的文本,在 WordPress 的联系表单 7 中。

据我所知,联系表格 7 没有给你这个选项,所以我用几行 jQuery 代码找到了这种方式,而且效果很好。

每次用户使用以下代码从下拉菜单中选择一个选项时,我都会显示一个额外的文本。

我的问题是,我不知道如何在邮件正文中传递额外的文本以便通过电子邮件发送。

现在,当我发送电子邮件时,我在消息正文中收到来自 [type-exam] 的“first-exam”或“second-exam”,但我还想在我的电子邮件中接收额外的文本。

有谁知道如何实现这一点,或者有没有其他解决方案可以让联系表 7 提供该选项?

谢谢

<div class="form-dropdown">
<label> Your choice
[select type_exam id:choice_exam include_blank "first-exam" "second-exam"]
</label>
</div>
<div id="option1" style="display:none;">first exam extra text...</div>
<div id="option2" style="display:none;">second exam extra text....</div>

<script>
$(document).ready(function () {
  $('#choice_exam').change(function () {
    var val = $(this).val();
    $('#option1').hide();
    $('#option2').hide();
    if (val == 'first-exam') {
      $('#option1').show();
    }
    else if (val == 'second-exam') {
      $('#option2').show();
    }
</script>

消息正文

Type exam: [type_exam]

【问题讨论】:

    标签: html jquery wordpress contact-form-7


    【解决方案1】:

    我找到了解决上述问题的方法。只需使用 |选项值中间的管道。

    <div class="form-dropdown">
    <label> Your choice
    [select type_exam id:choice_exam include_blank "first-exam | first exam extra text" "second-exam | second exam extra text"]
    </label>
    </div>
    

    Official doc 如果在选项值中间插入竖线(‘|’)字符,则只有竖线之前的部分对外开放,竖线之后的部分用于邮件更换。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-30
      • 2012-09-05
      • 2019-11-15
      • 1970-01-01
      • 2012-10-22
      • 2015-09-22
      • 2020-02-29
      • 1970-01-01
      相关资源
      最近更新 更多