In today's Internet world, the member system of websites and user grouping functions have become increasingly common. It not only helps operators provide differentiated services, but also is an important means to realize content monetization and enhance user stickiness.AnQi CMS knows this, so it built a powerful user group management and VIP system, allowing the website to flexibly provide customized content and permissions for different user groups.

How can we clearly display user group information (that is, VIP level) on the front-end page of a website built with Anqi CMS?This is actually more direct than I imagined.

Understand the user group and VIP system of AnQi CMS

The AnQi CMS user group management and VIP system, its core value lies in the fact that it allows us to classify users in a fine-grained manner and define unique permissions and attributes for each group.This includes the right to access specific content, the qualification for special services, and even the access to paid VIP content.This means that website operators can easily implement various membership levels such as 'Normal Member', 'Senior VIP', 'SVIP', and provide different content experiences according to these levels, thereby effectively supporting membership service and content monetization strategies.

The core idea of displaying user group information on the front-end page

We need to take two steps to display user group information on the website front end: first, we need to get the basic information of the currently logged-in user, and then, based on this basic information (especially the user group ID), we need to query the corresponding user group details.The template tag system of AnQi CMS provides convenient tools for completing these operations.

1. Get the basic information of the currently logged-in user

AnQi CMS providesuserDetailThe tag helps us retrieve various data of the currently logged-in user, including the user's ID, username, and key fields related to the membership level: GroupId(User Group ID) andExpireTime(VIP expiration time).

We can use it like thisuserDetailTag to get current user data:

{% userDetail currentUser %}

here,currentUserThis is a custom variable name that will carry all the information of the currently logged-in user. Through it, we can accesscurrentUser.Id/currentUser.UserName/currentUser.GroupId/currentUser.ExpireTimefields.

2. Retrieve detailed information based on the user group ID

When we start fromcurrentUserretrieve variableGroupIdAfter that, the next step is to use this ID to obtain more specific details about the user group, such as the name (such as "Golden Member"), description, or set level. At this point,userGroupDetailthe tag comes into play.

userGroupDetailLabels allow us to query the details of user groups by their ID or level. Combined with the information obtained from the previous step,GroupIdwe can use it in this way:

{% userGroupDetail currentGroup with id=currentUser.GroupId %}

Similarly,currentGroupIt is a custom variable that will contain the user group'sTitle(User group name),Description(Group introduction) andLevel(Group level) information.

3. Comprehensive Application: Display Member Level and VIP Status

Combine these two tags, and we can build a complete logic, displaying the user's membership level and VIP status at any position on the website (such as on the user center page, next to the top navigation bar). We will also useifTags are used to make conditional judgments to ensure that only logged-in users with specific membership levels display the corresponding information.

Here is an example of code to display a user's membership level in a template.

”`twig {# First, get all information of the currently logged-in user #} {% userDetail currentUser %}

{# Check if the user is logged in #} {% if currentUser.Id %}

<div class="user-info">
    <p>你好,<span class="user-name">{{ currentUser.UserName }}</span>!</p>

    {# 如果用户有指定的用户组(VIP),则显示其分组信息 #}
    {% if currentUser.GroupId %}
        {# 根据用户组ID获取用户组的