尝试获取联系表7将数据发布到屏幕上进行调试 [英] Trying to get contact form 7 post data to debug to screen

查看:59
本文介绍了尝试获取联系表7将数据发布到屏幕上进行调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试获取联系表单7的发布数据以调试表单提交,以便将其用于我尝试使用的插件.但是,当我使用var_dump或print_r时,我无法在任何地方获取数据.

I've been trying to get contact form 7 post data to debug the form submission so that I can use it for a plugin I'm trying to work on. However, when I use var_dump or print_r, I can't get the data anywhere.

我已经开始了.

add_action( 'wpcf7_before_send_mail', 'my_process_cf7_form_data' );
function my_process_cf7_form_data() {

    $submission = WPCF7_Submission::get_instance();
        if ( $submission ) {
            $posted_data = $submission->get_posted_data();    
    }
    var_dump($posted_data);
}

但是我没有任何输出.

推荐答案

您不能仅将这些数据转储到屏幕上,因为它是ajax函数的一部分.但是,您可以将其转储到错误日志中,并以bash结尾,或者使用FTP查看日志的输出.

You can't just dump this data to the screen, because it's part of an ajax function. You can however dump it to the error log and tail it in bash, or view the output of the log with FTP.

如果您改为这样做:

add_action( 'wpcf7_before_send_mail', 'my_process_cf7_form_data' );
function my_process_cf7_form_data() {

    $submission = WPCF7_Submission::get_instance();
        if ( $submission ) {
            $posted_data = $submission->get_posted_data();    
    }

    ob_start();
    var_dump($posted_data);
    error_log(ob_get_clean());

}

然后查看该域的php_error_log,或者是否启用了wp-debug并将错误记录到文件(在wp-config.php中).

then either view your php_error_log for this domain, or if you have wp-debug enabled and error logging to file (in your wp-config.php).

define( 'WP_DEBUG',         true );
define( 'WP_DEBUG_LOG',     true );

然后您可以在wp-content文件夹中查看debug.log.

then you can view the debug.log in wp-content folder.

这篇关于尝试获取联系表7将数据发布到屏幕上进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆