当未在WordPress中选中复选框时如何在表单中发送“否" [英] How to send 'no' in form when checkbox isn't checked in WordPress

查看:84
本文介绍了当未在WordPress中选中复选框时如何在表单中发送“否"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WordPress的联系表格7 插件中,是否可以发送自定义邮件发送到基于复选框值的邮件.在我的表格中,订阅新闻通讯复选框.当用户选中该复选框时,订阅的新闻邮件在邮件中显示为是".现在,当用户未选中复选框时,我想以否"发送订阅新闻通讯.

In contact form 7 plugin of WordPress, Is it possible to send custom message to mail based on checkbox value. In my form I have, subscribe to newsletter checkbox. When user checks the checkbox, subscribe to newsletter is coming as 'Yes' in mail. Now I want to send subscribe to newsletter as 'No' when user doesn't check the checkbox.

有可能吗?我尝试过并且仍在Google中寻找答案,但无济于事.欢迎任何帮助/建议.预先感谢.

Is it possible. I tried and am still searching for the answer in google but to no avail.Any help/suggestion is welcome. Thanks in advance.

推荐答案

最终得到了解决方案.

add_action("wpcf7_posted_data", "wpcf7_modify_this");
function wpcf7_modify_this($posted_data) {
    /* if checkbox isn't checked send Nej to mail */
    if ($posted_data['checkbox-829'][0] == "")
        $posted_data['checkbox-829'][0] = "Nej";

    return $posted_data;
}

我从DACrosby 这里.

I got this solution from answer of DACrosby here.

这篇关于当未在WordPress中选中复选框时如何在表单中发送“否"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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