In today's internet world, the membership system of websites and user grouping functions have become increasingly common. Not only can it help operators provide differentiated services, but it is also an important means to achieve content monetization and enhance user stickiness.The AnQi CMS understands this point, therefore it has built-in 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 (that is, VIP level) information on the front-end page of a website built with Safe CMS?This is much more direct than I imagined.

Understand the user group and VIP system of AnQi CMS for users

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

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

AnQi CMS providesuserDetailLabel, it can help us obtain various data of the current logged-in user, including the user's ID, username, and keywords related to the membership level:GroupId(User Group ID) andExpireTime(VIP expiration time).

We can use it like thisuserDetailLabel to retrieve current user data:

{% userDetail currentUser %}

Here,currentUserIt is a custom variable name we use, which will carry all the information of the currently logged-in user. Through it, we can accesscurrentUser.Id/currentUser.UserName/currentUser.GroupId/currentUser.ExpireTimeand other fields.

2. English for getting detailed information by user group ID

When we are fromcurrentUserget it from the variableGroupIdAfter that, the next step is to use this ID to obtain more specific details about the user group, such as the name of the user group (e.g. "Gold Member"), description, or set level.userGroupDetailTags come into play.

userGroupDetailTags 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 our custom variable, which will include information such as the user group.Title(User group name),Description(User group introduction) andLevel(User group level) information.

3. English Application: Display member level and VIP status on the page

Combine these tags, and we can build a complete logic, which can display the user's member level and VIP status at any location on the website (such as the user center page, next to the top navigation bar). We will also useifLabel the conditions for display, ensuring that only logged-in users with specific membership levels display the corresponding information.

Below is an example of a code snippet for displaying the 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获取用户组的