我在Wordpress中创建了一个自定义表单,用户填写了一些输入字段,并在提交表单时,现在收件人正在收到邮件 . 我需要的是当用户提交数据时,数据应该存储在联系表格DB中 . 使用Contact Form 7插件,存储所有数据,但我需要将自定义联系表单数据存储到联系表单7 db中 .
能帮我找一个可能的解决方案吗?
最后,找到了确切的解决方案 .
如果我们想以编程方式将数据推送到Contact Form DB,那么您需要了解两件基本事项:
How to struture your form data so that the plugin knows how to consume it How to call the plugin’s save data function
Data should be structured like this:
$data = (object) array( 'title' => 'form-name', 'posted_data' => array( 'fname' => $_POST['fname'], 'lname' => $_POST['lname'], 'email' => $_POST['email']);
其中'form-name'是表单的名称,'fname','lname'和'email'是此示例中的表单字段 . 用表单中的字段替换它们 .
Calling the Plugin
require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CF7DBPlugin.php'); $plugin = new CF7DBPlugin(); $plugin->saveFormData(&$data);
OR Use CF7's hook
do_action_ref_array( 'wpcf7_before_send_mail', array( &$data) );
使用CF钩子的优点是我们不需要包含CF7DBPlugin.php文件,它是一种解耦方法 . 缺点是任何其他监听钩子的插件也会得到数据 .
1 回答
最后,找到了确切的解决方案 .
如果我们想以编程方式将数据推送到Contact Form DB,那么您需要了解两件基本事项:
Data should be structured like this:
其中'form-name'是表单的名称,'fname','lname'和'email'是此示例中的表单字段 . 用表单中的字段替换它们 .
Calling the Plugin
OR Use CF7's hook
使用CF钩子的优点是我们不需要包含CF7DBPlugin.php文件,它是一种解耦方法 . 缺点是任何其他监听钩子的插件也会得到数据 .