【发布时间】:2019-10-26 02:43:12
【问题描述】:
我写了以下代码:
// define the wpcf7_mail_sent callback
function action_wpcf7_mail_sent( $contact_form ) {
$temp1246 = get_post_meta( 1246, $key = 'ID', TRUE);
$temp1246 = intval($temp1246) + 1;
update_post_meta( 1246, 'ID', $temp1246 );
};
// add the action
add_action( 'wpcf7_mail_sent', 'action_wpcf7_mail_sent', 10, 1 );
代码的作用是每次提交联系表单时都会将页面的自定义值加 1。但是我现在遇到的问题是,我只想要一个特定的联系表单在发送时触发此代码,而不是所有的联系表单(我在由 CF7 提供支持的站点中有一些联系表单)。
我可以知道如何调整上面的代码,使其仅在发送联系表单 (id = '1000') 时触发?
如果有人可以提供帮助,谢谢!
【问题讨论】: