欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

wordpress用户注册_如何显示WordPress中的注册用户总数

程序员文章站 2022-04-17 13:26:02
...

wordpress用户注册

Have you ever wanted to show the total number of registered users on your WordPress site? Social proof like showing the number of registered users on your site, encourages others to register as well. In this article, we will show you how to show total number of registered users in WordPress.

您是否曾经想显示您的WordPress网站上的注册用户总数? 社会证明,例如显示您网站上注册用户的数量,也鼓励其他人也进行注册。 在本文中,我们将向您展示如何显示WordPress中的注册用户总数。

wordpress用户注册_如何显示WordPress中的注册用户总数

方法1:使用WordPress插件显示注册用户数 (Method 1: Show Registered User Count Using a WordPress Plugin)

First thing you need to do is install and activate the Simple Blog Stats plugin. For more details, see our step by step guide on how to install a WordPress plugin.

您需要做的第一件事是安装并**Simple Blog Stats插件。 有关更多详细信息,请参阅有关如何安装WordPress插件的分步指南。

Upon activation, you need to visit Settings » Simple Blog Stats page to configure plugin settings.

**后,您需要访问设置»简单博客统计信息页面来配置插件设置。

wordpress用户注册_如何显示WordPress中的注册用户总数

This plugin allows you to show different stats from your WordPress site. You need to click on the shortcodes tab to expand it and then scroll down to the ‘number of users’ row.

该插件可让您显示WordPress网站的不同统计信息。 您需要单击“简码”选项卡将其展开,然后向下滚动到“用户数”行。

wordpress用户注册_如何显示WordPress中的注册用户总数

You will see the shortcode [sbs_users] with two text fields on both sides. These text fields contain HTML the plugin will add before and after the number of users.

您将看到在两侧都有两个文本字段的简码 [sbs_users] 。 这些文本字段包含插件将在用户数量之前和之后添加HTML。

By default, the shortcode will output HTML like this:

默认情况下,简码将输出如下所示HTML:


<span class="sbs-count-users">856</span>

If you are unsure, then just copy the shortcode [sbs_users] and click on the save settings button.

如果不确定,则只需复制简码[sbs_users] ,然后单击“保存设置”按钮。

You can now add this shortcode to any WordPress post or page. You can also add it to a sidebar widget. If the shortcode does not work in the widget, then follow instructions in our guide on how to use shortcodes in your WordPress sidebar widget.

现在,您可以将此简码添加到任何WordPress 帖子或页面中 。 您也可以将其添加到侧边栏小部件中 。 如果该短代码在窗口小部件中不起作用,请按照我们的指南中有关如何在WordPress边栏窗口小部件中使用短代码的说明进行操作

方法2:使用代码手动显示WordPress中的注册用户数 (Method 2: Manually Show Number of Registered Users in WordPress with Code)

This method requires you to add code to your WordPress site. If you haven’t done this before, then see our beginner’s guide on pasting snippets from web into WordPress.

此方法要求您将代码添加到WordPress网站。 如果您以前从未这样做过,请参阅有关将网页摘要粘贴到WordPress的初学者指南。

You need to add the following code to your theme’s functions.php file or a site-specific plugin.

您需要将以下代码添加到主题的functions.php文件或特定站点的插件中


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

This code creates shortcode [user_count] which you can use in your WordPress posts, pages, or a sidebar widget to display the user count.

这段代码创建了简码[user_count] ,您可以在WordPress帖子,页面或侧边栏小部件中使用它来显示用户数。

The function does not add any HTML formatting to the user count and simply returns the number. You may want to wrap the shortcode around HTML to use CSS or basic HTML formatting. For example:

该函数不会向用户计数中添加任何HTML格式,而只是返回数字。 您可能需要将简短代码包装在HTML周围,以使用CSS或基本HTML格式。 例如:


<p>Join <strong>[user_count]</strong> other users who share your interest:</p>

Here is how it looked on our demo site:

这是在我们的演示站点上的外观:

wordpress用户注册_如何显示WordPress中的注册用户总数

Note: We added a free signup button that redirected to a custom WordPress user registration page.

注意:我们添加了一个免费的注册按钮,可将其重定向到自定义WordPress用户注册页面

That’s all, we hope this article helped you learn how to show the total number of registered users in WordPress. You may also want to see our guide on how to moderate new user registrations in WordPress.

仅此而已,我们希望本文能帮助您学习如何显示WordPress中的注册用户总数。 您可能还希望查看我们的指南,了解如何审核WordPress中的新用户注册

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

如果您喜欢这篇文章,请订阅我们的YouTube频道 WordPress****。 您也可以在TwitterFacebook上找到我们。

翻译自: https://www.wpbeginner.com/wp-tutorials/how-to-show-total-number-of-registered-users-in-wordpress/

wordpress用户注册