问题描述
我在网站上使用联系表 7,需要更改复选框提交的数据.复选框有一个名为勾号的标签,如果您不想接收进一步营销,则在检查Admins通知电子邮件中发送的值显示复选框标签.所以它看起来像:
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 提交数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!