联系表格7不显示成功消息?

时间:2020-05-30 10:17:21

标签: php wordpress contact-form-7

我已经复制了有关联系表格7 wordpress的代码,当前数据已成功发送到外部数据库,但是成功消息几乎没有显示,我也移到了“谢谢”页面。谢谢

function wpcf7_send_to_external ( $cf7 ) {

//external db details
$username = 'username';
$password = 'pass';
$database = 'database';
$host = 'myip';


//create new wpdb instance
$mydb = new wpdb($username, $password, $database, $host);


        $cf7 = WPCF7_ContactForm::get_current();
        $submission = WPCF7_Submission::get_instance();
        $data = $submission->get_posted_data();


        $field1 = $data["name"];
        $field2 = $data["semail"];
        $field3 = $data["phone"];
        $field4 = $data["nhu"];


        //insert into external db
        $mydb->insert( 

            'customer',

            array( 
                'name' => $field1, 
                'email' => $field2,
                'phone' => $field3,
                'content' => $field4
            ),

            array( 
                '%s','%s','%s','%s'
            ) 
        );

}

add_action(“ wpcf7_before_send_mail”,“ wpcf7_send_to_external”);

1 个答案:

答案 0 :(得分:0)

这看起来像是从JavaScript文件中调用的,您可以在其中执行console.log。

console.log("Success message!");

如果您需要PHP文件中的数据,则可以将其发送回显。 (可以将其作为对HTTP请求的响应来访问。

echo "some data: $variable";