如何将存储在数据库中的联系人表单7值链接到特定用户-Wordpress



我创建了一个联系人表单7多步骤表单(4个步骤(,并安装了一个插件将值保存到数据库中。我还可以看到保存在数据库中的值。

我想要的是将这些问题作为可编辑版本显示在用户配置文件中,这样用户就可以编辑他在所有4个表单中输入的详细信息,并且这应该在数据库中更新。

现在我正在使用终极会员插件进行用户注册。这很好,但我不知道如何将用户与他的应用程序链接(将用户链接到数据库中保存的表单值,以便我可以相应地显示每个用户的值(

我对文字出版社完全陌生。任何帮助都将不胜感激。谢谢

我将使用CF7的Smart Grid Layout扩展和Post My CF7 Form扩展的组合,因为这两个扩展彼此兼容。

智能网格插件允许您使用单个表单构造(而不是单独的表单(构建多步骤表单,可以使用滑块显示或手风琴。要了解如何使用智能网格构建多幻灯片表单,请参阅本视频教程。

张贴我的CF7表格允许您将表格映射到帖子(或自定义帖子(,而不是在数据库中创建表格。这样做的好处是,保存到帖子的每个子表格也将登录用户关联为帖子的作者。

如果你的用户可以访问你网站的仪表板,他们可以使用帖子编辑器编辑他们的帖子,否则,如果你需要他们在前端编辑帖子,插件可以将保存的帖子及其值重新加载到给定用户的表单中,你可以使用以下过滤器来实现这一点,

add_filter('cf7_2_post_filter_user_draft_form_query', 'filter_user_post_for_prefill', 10, 3);
/**
* Function to filter the post query for current user in order to prefill form.
* For draft forms (using the save button), this query is configured to load the latest draft submission.
* However, this filter can be used to modify the query for  submitted form that need editing.
* @param Array $query_args array query args for function get_posts().
* @param String $post_type post type being mapped to.
* @param String $form_key unique key identifying the current form.
* @return Array array of query parameters (for more info see the WordPress codex page on get_posts).
*/
function filter_user_post_for_prefill($query_args, $post_type, $form_key){
//modifying the query to retrieve the last submitted post for the current user.
//the plugin stores a flag '_cf7_2_post_form_submitted' as a meta field to identiy
//if a form is submitted or saved as a draft. No for drafts, Yes for submitted.
$query_args['meta_query']['value']='yes';
return $query_args;
}

最新更新