【问题标题】:Contact form 7 not show success message?联系表格 7 不显示成功消息?
【发布时间】:2020-06-01 13:14:27
【问题描述】:

我已经复制了关于contact form 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");

【问题讨论】:

标签: php wordpress contact-form-7


【解决方案1】:

这看起来像是从一个 JavaScript 文件中调用的,你可以在那里做一个 console.log。

console.log("Success message!");

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

echo "some data: $variable";

【讨论】:

  • 谢谢,我加了一些代码,if ($submission) , if (empty ($posted_data)) return ;
猜你喜欢
  • 2021-10-26
  • 2015-07-25
  • 2021-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-05
  • 2014-05-05
相关资源
最近更新 更多