【问题标题】:Wordpress Contact Form 7 writing to DatabaseWordpress 联系表 7 写入数据库
【发布时间】:2020-12-20 07:54:40
【问题描述】:

我将以下代码添加到我的 functions.php 文件中,但我似乎无法将联系表单写入 Wordpress 数据库。我可以让它写一个新行,但它不会保存任何表单数据。有人有什么建议吗?

enter code here

function contactform7_before_send_mail( $form_to_DB )
{
//set your db details
$mydb = new wpdb('username','password','dbname','host');

$form_to_DB = WPCF7_Submission::get_instance();
if ( $form_to_DB )
    $formData = $form_to_DB->get_posted_data();
$title = $formData['title'];

$mydb->insert( 'name of db', array( 'title' =>$title ), array( '%s' ) );

remove_all_filters ('wpcf7_before_send_mail');
add_action( 'wpcf7_before_send_mail', 'contactform7_before_send_mail' );

【问题讨论】:

    标签: php mysql wordpress contact-form-7


    【解决方案1】:

    您只需要安装 Advanced Contact form 7 DB plugin.so 它将存储表单提交的所有数据。

    【讨论】:

      猜你喜欢
      • 2012-06-25
      • 1970-01-01
      • 1970-01-01
      • 2016-04-20
      • 2018-07-18
      • 2016-12-23
      • 2020-05-30
      • 2023-03-18
      • 1970-01-01
      相关资源
      最近更新 更多