AnQi CMS provides us with a powerful and flexible user group and VIP system, not only to distinguish between ordinary users and members, but also to manage the website content in fine detail, so that different user groups can see different information, and even decide whether they can access certain specific content based on their level.This is an extremely important feature for websites that operate paid content, provide exclusive member services, or customize browsing experiences based on user identity.
What can the user group and VIP system do for us?
Imagine that your website has both free public articles and in-depth reports that require payment to read, or some content is only open to long-term supporting loyal members.If there is no mechanism to distinguish these users, it will be very麻烦 to manage.The Anqi CMS user groups and VIP system are designed to solve this problem.
What can we do through this system:
- Achieve content monetization: Set some high-quality content as VIP exclusive, guide users to pay for subscription or upgrade membership, thereby bringing income to the website.
- Provide differentiated services: Show different level content based on the different levels of users (such as ordinary members, gold members, diamond members), to enhance the sense of exclusivity and value for members.
- optimize user experienceLet different users see the content most relevant to their identity, avoid interference from irrelevant information, and enhance the professionalism and usability of the website.
- Refined operation: Post notifications, events, or recommended content for specific user groups to increase user activity and conversion rates.
In short, it allows us to manage content more flexibly and intelligently, meet the needs of different user groups, and provide strong support for the business model of the website.
How to set up user groups and VIP system in AnQi CMS?
In the Anqi CMS backend, we can find the core feature of "User Group Management and VIP System". The configuration process is intuitive and easy to operate.
First, we need to create and configure different user groups. Each user group can define its own:
- nameFor example, 'General User', 'Monthly VIP', 'Annual VIP', 'Partner' and so on, convenient for identification.
- IntroductionPlease give a brief description of this user group.
- levelThis is a very critical number. We can set a level value for user groups, such as 0 for ordinary users, 1 for monthly VIPs, 2 for annual VIPs, and the higher the number, the higher the level.This level will be directly used for subsequent content access permission judgment.
- Purchase price and discountIf the user group is a paid VIP, the price can be set and discount options can be provided.
In addition to these basic information, each user group also supports a very powerful "Settings" function.This is a custom key-value pair area, like attaching one or more custom tags to a user group.For example, we can add a setting item for the "Annual VIP" user group with the key namedcan_download_premium_reportwith a value oftrue; or set for 'Normal User'has_ad_free_experiencewith a value offalseThese custom settings will take effect in the template, helping us to implement more complex logical judgments.
How to control the access permissions of specific content?
Now, we have different user groups, and we have set levels and custom permissions for them.How to associate these permissions with the specific content on the website.Our CMS achieved this through logical judgments in the content model fields and templates.
Mark restricted contentWhen we publish articles, products, or create single-page applications, the Anqicms content model allows us to add custom fields to the content. The document mentions
ReadLevelThis field, this is the key to controlling access to content. We can set up one for a piece of content.ReadLevelFor example, an open article'sReadLevelCan be 0, a VIP article can be 1, an exclusive report can be 2. This means that only users with a group level of or higher than the contentReadLevelcan access.Determine user permissions in the templateAfter the content is published, we need to write logic code in the website's front-end template to determine whether to display the content based on the level of the visitor. This is mainly through
userDetail/userGroupDetailandarchiveDetailthese tags, combinedifLogic judgment tag to implement.Assuming we want an article (ID 100) to be readable only by VIP users (assuming the VIP user group level is 1), ordinary users can only see the prompt. This can be written in the template of the article detail page:
{# 1. 获取当前访问用户的ID #} {%- userDetail currentUser with name="Id" %} {# 2. 如果用户已登录,则获取其所在用户组的等级;否则,默认等级为0(未登录用户) #} {% set userLevel = 0 %} {% if currentUser %} {%- userGroupDetail userGroup with name="Level" id=currentUser.GroupId %} {% set userLevel = userGroup %} {% endif %} {# 3. 获取当前文章所需的阅读等级 #} {%- archiveDetail articleReadLevel with name="ReadLevel" %} <article> <h1>{{ archive.Title }}</h1> <div class="article-meta"> <span>发布日期: {{ stampToDate(archive.CreatedTime, "2006-01-02") }}</span> <span>浏览量: {{ archive.Views }}</span> </div> {% if userLevel >= articleReadLevel %} {# 如果用户等级满足,则显示文章内容 #} <div class="article-content"> {{ archive.Content|safe }} </div> {% else %} {# 如果用户等级不足,则显示提示信息 #} <div class="restricted-content-message"> <p>此内容为VIP专属,您当前等级为 {{ userLevel }},文章所需等级为 {{ articleReadLevel }}。</p> {% if not currentUser %} <p>请 <a href="/login">登录</a> 查看,或 <a href="/vip-upgrade">升级VIP</a> 立即解锁!</p> {% else %} <p>您的当前等级不足,请 <a href="/vip-upgrade">升级VIP</a> 立即解锁!</p> {% endif %} </div> {% endif %} </article>This code first checks if the user is logged in. If logged in, it retrieves the level of the user group the user belongs to;If not logged in, the default level is 0. Next, it retrieves the requirements of the current article.
ReadLevel. Finally, by comparing these two levels, decide whether to display the full content or a friendly prompt.
How to customize the display status of the content?
In addition to controlling the access permissions of content, the Anqi CMS user groups and VIP system also allows us to more flexibly control the display status of content in different scenarios.
- Display "VIP Exclusive" label on the content list pageIn article lists, product lists, and other pages, we may want to have a "VIP exclusive" badge next to the restricted content, which can attract ordinary users to click and also clearly indicate the nature of the content. "`twig {% archiveList archives with type=“page” limit=“10” %} {% for item in archives %}
-
{{item.Title}} {# Get the article's reading level, if it is greater than 0, display the VIP indicator #} {%- archiveDetail articleReadLevel with name=“ReadLevel” id=item.Id %} {% if articleReadLevel > 0 %}Exclusive VIP{% endif %}
{{item.Description|truncatechars:100}}{% endfor %}
{% end