AutoCMS provides us with a powerful and flexible user group and VIP system. This is not only to distinguish between ordinary users and members, but also to manage the website content in detail, so that different user groups can see different information, and even determine 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 the browsing experience based on user identity.

What can the user group and VIP system do for us?

Imagine, your website has free open articles, as well as 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 user group and VIP system of AnQi CMS is designed to solve this problem.

With this system, we can:

  1. Monetize contentSet some high-quality content as VIP exclusive, guiding users to pay for subscription or upgrade membership, thus bringing income to the website.
  2. Provide differentiated servicesBased on the different levels of users (such as ordinary members, gold members, diamond members), display different level content to enhance the sense of exclusivity and value of members.
  3. Optimizing user experienceLet different users see the content most relevant to their identity, avoid irrelevant information interference, and enhance the professionalism and ease of use of the website.
  4. Refined operation:Publish notifications, activities, 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 backend of AnQi CMS, we can find the core feature of 'User Group Management and VIP System'. The configuration process is intuitive and easy to operate.

Firstly, we need to create and configure different user groups in the background. Each user group can define its own:

  • Name:For example, 'General User', 'Monthly VIP', 'Annual VIP', 'Partner' and so on, which is convenient for us to identify.
  • Introduction:Provide 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 VIP, and 2 for annual VIP. The higher the number, the higher the level.This level will be used directly for subsequent content access permission judgment.
  • Purchase price and discount priceIf the user group is a paid VIP, you can set the price and provide discount options.

In addition to this basic information, each user group also supports a very powerful "Settings" feature.This is a customized key-value pair area, like attaching one or more customized tags to this user group.can_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 achieve 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.Next, it is about how to associate these permissions with specific content on the website.AutoCMS achieves this through field and logic judgment in the content model and templates.

  1. Mark restricted content: When we publish articles, products, or create single-page applications, the content model of the Anqi CMS allows us to add custom fields to the content. The document mentionsReadLevelThis field, that is the key to controlling access to content. We can set access permissions for a piece of content.ReadLevelFor example, a public article'sReadLevelThis can be 0, a VIP article can be 1, an exclusive report can be 2. This means that only users with a group level equal to or higher than this contentReadLevelcan access.

  2. In the template, determine user permissions: Content published, we need to write logic code in the front-end template of the website to determine whether to display the content based on the user's level of access. This is mainlyuserDetail/userGroupDetailandarchiveDetailthese tags, combinedifLogical judgment label to implement.

    The article (ID 100) should only be readable by VIP users (assuming the VIP group level is 1), while regular users can only see a prompt. You can write it like this 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 will get the level of the user group the user belongs to; if not logged in, the default level is 0.ReadLevel. Finally, by comparing these two levels, decide whether to display the full content or a friendly prompt message.

How to customize the display status of the content?

In addition to controlling the access permissions of content, the user groups and VIP system of the Aanqi CMS allow us to more flexibly control the display status of content in different scenarios.

  1. Display “VIP Exclusive” on the content list pageIn article lists, product lists, and other pages, we may want a 'VIP Exclusive' badge next to restricted content, which can attract regular users to click and clearly indicate the nature of the content. twig {% archiveList archives with type=“page” limit=“10” %} {% for item in archives %}
  2. VIP Exclusive{% endif %}
    {{item.Description|truncatechars:100}}
  3. {% endfor %} {% end