您可以从数组变量获取post ID$posted_data
表单发送自
if ($submission) {
$posted_data = $submission->get_posted_data();
print_r($posted_data)
}
如果你做了
print_r
在上面你会看到这样的东西:
Array
(
[_wpcf7] => 20
[_wpcf7_version] => 5.1.6
[_wpcf7_locale] => en_US
[_wpcf7_unit_tag] => wpcf7-f20-p22-o1
[_wpcf7_container_post] => 22 **//This is what you want.**
[your-name] => Jon Doe
[your-email] => [email protected]
[your-subject] => subject
[your-message] => message
)
编辑:
自CF7起version 5.2 获取;post"E;联系人表单绑定的ID为:
if ($submission) {
print_r($_POST);
}
这将返回如下结果:
Array
(
[_wpcf7] => 119 **//This is the "contact form" ID. But one should get that using WPCF7_ContactForm::get_current(); method **
[_wpcf7_version] => 5.2.1
[_wpcf7_locale] => en_US
[_wpcf7_unit_tag] => wpcf7-f119-p120-o1
[_wpcf7_container_post] => 120 **//This is the "post" ID**
[_wpcf7_posted_data_hash] =>
[your-name] => Jon
[your-email] => Doe
[your-subject] => Test
[your-message] => Test
)