修改联系表7提交数据 [英] Modify Contact Form 7 Submission Data

查看:80
本文介绍了修改联系表7提交数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在网站上使用联系表格7,需要更改复选框提交的数据。该复选框带有一个名为如果您不想进一步营销,请在此处打勾的标签,如果选中此复选框,则管理员通知电子邮件中发送的值将显示该复选框标签。
这样看来:

I'm using Contact Form 7 on a site and need to alter the checkbox submitted data. The checkbox has a label called 'Tick here if you dont want to receive further marketing', when this is checked the value sent in the admins notification email displays the checkbox label. So it looks like:

如果您不想接受进一步的营销,请在此处勾选:如果您不想接受进一步的营销,请在此处勾选

Tick here if you dont want to receive further marketing: Tick here if you dont want to receive further marketing

我想对其进行更改,以便当其选中时显示的值为否。

I want to alter it so when its checked the value posted is No.

我相信我可以使用以下操作挂钩实现此功能,但我不知道如何检查此功能中的复选框是否已被勾选并修改其值。

I believe I can use the following action hook to achieve this but I dont know how to check if the checkbox has been ticked within this function and modify its value.

任何帮助都非常感谢。

// define the wpcf7_posted_data callback 
function action_wpcf7_posted_data( $array ) { 
// make action magic happen here... 
}; 

// add the action 
add_action( 'wpcf7_posted_data', 'action_wpcf7_posted_data', 10, 1 );


推荐答案

我相信您可以使用:

// define the wpcf7_posted_data callback 
function action_wpcf7_posted_data( $array ) { 
    //'checkbox-name' is the name that you gave the field in the CF7 admin.
    $value = $array['checkbox-name'];
    if( !empty( $value ) ){
        $array['checkbox-name'] = "New Value";
    }

    return $array;
}; 
add_filter( 'wpcf7_posted_data', 'action_wpcf7_posted_data', 10, 1 );

这篇关于修改联系表7提交数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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