php - 联系表格 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");
解决方案
这看起来像是从 JavaScript 文件中调用的,您可以在那里执行 console.log。
console.log("Success message!");
如果您需要 PHP 文件中的数据,您可以通过回显将其发回。(可以作为对 HTTP 请求的响应进行访问。
echo "some data: $variable";
推荐阅读
- java - Spring Boot application.yml 全局设置数据源属性,被忽略
- java - 为什么字符串转换不是数字提升的一种?
- flutter - Dart 中的懒惰单例与单例
- powershell - 将文件文本转换为 Hashtable 并使用键读取值?
- r - 脚本可能有我找不到的语法问题
- reactjs - Firefox 自动填充将输入置于加载 div 之上
- firebase - 在颤振中使用 Firebase Google_signin 选项时出错
- kubernetes - 只能通过应用运行的工作节点访问 NodePort 服务
- python - For 循环 + 布尔值
- android - 如何解释 Android 微调器的方向大小变化?