[英]Contact form 7 not show success message?
我已經復制了關於聯系表格 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");
這看起來像是從 JavaScript 文件中調用的,您可以在那里執行 console.log。
console.log("Success message!");
如果您需要 PHP 文件中的數據,您可以通過回顯將其發回。 (可以作為對 HTTP 請求的響應訪問。
echo "some data: $variable";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.