如何显示使用 Wordpress 中的 forminator 插件填写注册表的人数?

How to show number of people that have filled out a registration form using forminator plugin in Wordpress?

我正在使用 Wordpress 中的 Forminator 插件来创建用户可以注册的“挑战”部分。为了报名参加这项挑战,要求用户填写一份注册表,要求提供一些个人信息。

我现在的目标是能够在网站上显示有多少人报名参加了挑战,所以本质上是一个计数器,显示有多少人填写了表格,就好像人数一样参加一个活动。有什么办法吗?我将 Wordpress 与 Elementor 页面编辑器以及表单的 Forminator 插件一起使用。

您可以通过将代码添加到您的 functions.php 文件来显示注册用户数

// Function to return user count
function custom_user_count() { 
$usercount = count_users();
$result = $usercount['total_users']; 
return $result; 
} 
// Creating a shortcode to display user count
add_shortcode('user_count', 'custom_user_count');

然后将以下短代码添加到您的 Elementor 块中:

[user_count]

要仅获取 Forminator 插件的用户数,请使用:

function get_all_submission_count() {
    ob_start();
    global $wpdb;
    $table_name = $wpdb->prefix . 'frmt_form_entry';
    $count_query = "select count(*) from $table_name";
    $count = $wpdb->get_var($count_query);
    return $count;
}

UPD

要在没有任何注册/数据库问题的情况下获得提交,请使用以下代码段:

根据此信息:

https://wpmudev.com/forums/topic/show-forminator-form-submission-count-in-the-front-end/

您可以从此处下载代码段: https://gist.github.com/wpmudev-sls/f0f3068ae2647cba05911a5374b38447

下载后,您可以解压缩并将 wpmudev-formator-shortcode-show-submissions.php 文件上传到您网站的 wp-content/mu-plugins 目录。