In Anqi CMS, implementing personalized information display based on the user group the user belongs to, such as their VIP level, is a key step to enhancing website user experience and content monetization capabilities.The AnQi CMS provides a powerful and flexible user group management feature, which can be easily implemented in the front-end template through simple template tag combinations.

Understand the user group and VIP system of AnQi CMS

One of the core advantages of AnQi CMS is its user group management and VIP system.This means we can divide the different permission levels for website users, such as ordinary users, VIP members, senior VIP members, and so on.These user groups can not only have different operation permissions, but can also associate specific content access permissions, and even define exclusive VIP levels.To display this information on the website front-end, we need to rely on the two important template tags provided by Anqi CMS:userDetailanduserGroupDetail.

Core feature tag parsing

To obtain and display user details and their group information, we will mainly useuserDetailanduserGroupDetailThese tags.

1. Get current user basic information:userDetailTag

userDetailThe tag is used to retrieve detailed data for a specific user. When a user is logged in, the context of the page usually provides the ID of the currently logged-in user, which we can use to query the specific information of the user.

The usage method of this tag is as follows:{% userDetail 变量名称 with name="字段名称" id="用户ID" %}

Among them:

  • 变量名称: Used to store the custom variable name of the query result, for examplecurrent_user_data.
  • name: Specify the user fields to be retrieved, for exampleUserName(Username),GroupId(User Group ID),ExpireTime(VIP expiration time) etc.
  • idSpecify the user ID to query. In practice, if it is to display information about the currently logged-in user, this ID is usually automatically provided by the system to the template, for example{{currentUser.Id}}or similar variables.

For example, if we want to get the username and user group ID of the currently logged-in user:

{# 假设当前页面上下文提供了登录用户的信息,例如 currentUser.Id #}
{% userDetail current_user_data with id=currentUser.Id %}
<p>用户名:{{ current_user_data.UserName }}</p>
<p>用户组ID:{{ current_user_data.GroupId }}</p>
{# 可以直接通过 current_user_data.ExpireTime 获取VIP过期时间戳 #}
<p>VIP过期时间戳:{{ current_user_data.ExpireTime }}</p>

2. Query user group details:userGroupDetailTag

userGroupDetailThe tag is used to obtain detailed data of the user group. ThroughuserDetailLabel gets the user'sGroupIdAfter that, we can pass this ID touserGroupDetailLabel to query the specific information of the user group to which the user belongs, such as VIP level, group name, etc.

The usage method of this tag is as follows:{% userGroupDetail 变量名称 with id="用户组ID" %}or{% userGroupDetail 变量名称 with level="用户组等级" %}

Among them:

  • 变量名称: It is also a custom variable name, for examplegroup_info.
  • idorlevel: Specify the user group ID or user group level to be queried, either one can be chosen.

The fields available for this tag include:Title(User group name),Description(Group introduction),Level(Group level),Price(Purchase price) etc.

For example, get the name and level of the user group with ID 1:

{% userGroupDetail vip_group with id="1" %}
<p>用户组名称:{{ vip_group.Title }}</p>
<p>用户组等级:{{ vip_group.Level }}</p>

Composite application: Display the VIP level and expiration time of the user

Now, let us