1 回答
TA贡献1866条经验 获得超5个赞
您无法回显输出,因为没有地方可以回显它。表单过程全部是 ajax。wpcf7_before_send_mail
但是,您可以将其输出到error_log或文件。这是将表单数据输出到error_log的示例。
add_action('wpcf7_before_send_mail', 'output_cf7_form_data');
function output_cf7_form_data(){
// Call the form data from the static instance of the class
$submission = WPCF7_Submission::get_instance();
if ( $submission ) {
// assign the posted data to an array
$posted_data = $submission->get_posted_data();
$name = $posted_data["your-name"];
}
// Use Output Buffering to print_r form data to the error log
ob_start();
print_r($posted_data);
echo 'Posted Name is ' . $name;
$body = ob_get_clean();
error_log($body);
}
如果您愿意,可以更改有关将其放入错误日志的部分,并使用 将信息发布到文件中。fwrite
如果你想看看这个联系表单7到常量联系API方法我曾经使用过的常量联系API,你可以看到我在发送邮件之前如何使用来捕获表单数据,但是在完成后推送到API,以便表单提交不会等待API调用完成, 并且用户在 API 调用发生时看不到小 ajax 微调器。wpcf7_mail_sent
- 1 回答
- 0 关注
- 113 浏览
添加回答
举报
