我在一个网站上使用联系人表单7,需要修改提交数据的复选框。该复选框有一个名为“如果您不想再收到营销信息,请在此处勾选”的标签,如果选中此选项,则管理员通知电子邮件中发送的值将显示该复选框标签。所以它看起来是这样的:
如果你不想接受进一步的营销,请在这里勾选:如果你不想接受进一步的营销,请在这里勾选
我想改变它,以便当它检查时,张贴的值是否。
我相信我可以使用以下操作钩子来实现这一点,但我不知道如何检查此函数中的复选框是否已被勾选并修改其值。
任何帮助都非常感谢。
// 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 );
发布于 2016-10-13 01:57:50
我相信你可以直接使用:
// 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 );
https://stackoverflow.com/questions/40000543
复制相似问题