add_action("wpforms_process_complete", 'function_save_custom_form_data');
function function_save_custom_form_data($params) {
foreach($params as $idx=>$item) {
$field_name = $item['name'];
$fiel_value = $item['value'];
// Do whatever you need
}
return true;
}
/*hook to save entries coming from WPforms into database*/
add_action( 'wpforms_process_entry_save', array( $this, 'ank_wpforms_save_entries' ), 10, 4 );
public function ank_wpforms_save_entries( $fields, $entry, $form_id, $form_data ) {
//no need to sanitize data coming from WPForms as it is being sanitized in WPForms plugin before this hook using
//wpforms_process_validate_{$field_type} in class-process.php
$data = array();
$data['form_id'] = $form_id;
$data['entry_details'] = $fields;
//additional sanity checks are also performed while json encoding in "add" before adding in database
ank_wpforms_entry()->get_class_instance( 'entry-db' )->add( $data );
}
wp_wpforms_entries: In this table, the field values for entries are stored.
wp_wpforms_entry_meta: This table contains meta information about your entries such as IDs associated and the date that entries were submitted.
4条答案
按热度按时间sqserrrh1#
如果您使用的是wp forms-lite,您不能直接这样做,要么您需要升级到pro版本,要么构建您自己的自定义保存操作。
如果您决定使用自己的自定义版本,下面将详细介绍如何在wp表单上交互表单提交。
wpforms有一些操作可用于在表单提交后执行自己的自定义操作:
WPU表格\流程\完成
通过在您自己的模板或插件上使用wordpress钩子add\u操作来处理所描述的任何事件,您可以获得表单数据并执行所需的处理。
wordpress添加操作的参考可以在官方文档中看到。https://developer.wordpress.org/reference/functions/add_action/
做了一个简短的片段,可以帮助您入门:
如果你需要更多的细节,请告诉我。
nhn9ugyo2#
wpforms的免费版本不保存表单中捕获的条目详细信息。因此,您需要编写自定义代码来保存自定义db表中的值,然后显示它们。
wpforms的钩子可以用来保存在wpforms中输入的数据
或者,您可以使用这个免费插件将来自wpforms的条目保存到wordpress数据库中,然后在wordpress Jmeter 板中显示它们-https://wordpress.org/plugins/add-entries-functionality-to-wpforms/
093gszye3#
例如,创建自定义表
wpforms_entries
以及wpforms_entry_meta
在数据库中存储表单数据。使用提供的行动钩wpforms_process_complete
以存储表单条目。参考文献:https://github.com/sanzeeb3/entries-for-wpforms/blob/master/includes/functions-wpfe-core.php#l59
或者,插件本身也可用:https://wordpress.org/plugins/entries-for-wpforms/
gv8xihay4#
wpforms将所有表单数据存储在原生wordpress数据库中的两个表中。他们是:
发布表单后,请确保添加表单条目,以便我们可以从您的wordpress Jmeter 板访问该条目。此外,在窗体生成器中,转到“设置”» 并确保存储在wordpress中的条目未被禁用。