In content operation, it is a common strategy to exclusively present some high-quality content to VIP users.This can not only enhance user stickiness and promote user conversion, but also is an important way to achieve content monetization.AnQiCMS provides a complete user group management and content permission control feature, allowing you to easily implement the need for specific content to be visible only to VIP user groups.

Back-end settings: Distinguish users and content

Implement VIP exclusive content visibility, you first need to perform two key configurations in the AnQiCMS backend: user group management and content permission settings.

第一步:Create and Configure VIP User Group

AnQiCMS has built-in powerful user group management functions, allowing you to finely divide user permissions.You need to enter the "User Group Management" module on the backend to create or edit your VIP user group.For example, you can create a user group named "Senior Member" and set a clear "reading levelThis level will become an important basis for subsequent judgments on the access rights to the content.In addition to reading levels, you can also configure other privileges for the VIP user group, such as whether to allow commenting and whether to be ad-free, which provides great flexibility for your membership system.

第二步:Set Exclusive Reading Permissions for Specific Content

When you edit or publish any document (whether it's an article, product, single page, or any entry under other custom content models), AnQiCMS provides fine-grained permission control.On the content editing page, you will find a 'Reading Level' option.When you want an article or product to be visible only to VIP users, you just need to set the 'reading level' of the content to match the reading level of your VIP user group (for example, if the reading level of your 'senior member' user group is '2', then set the reading level of this VIP content to '2' or higher).

Through this method, AnQiCMS establishes a direct association between content access permissions and user group levels.Non-VIP users will not be able to access this content, which has been set with specific reading levels.

Front-end Template Implementation: Intelligent Judgment and Display

Although the backend has completed the binding of permissions, the final presentation of content needs to be completed through logical judgments in the front-end template.AnQiCMS's template engine supports tag syntax similar to Django, allowing you to easily write conditional judgment logic.

Step 3: Judge user identity and content permission in the template

When a user accesses a page, your website template needs to execute the following judgment logic:

  1. Get the current user status:Determine if the user is logged in. If logged in, retrieve the user group ID they belong to.
  2. Get user group details:Retrieve the detailed information of the user group based on the user group ID, especially its set 'reading level'.
  3. Get content reading level:Get the 'reading level' of the content displayed on the current page.
  4. Perform a permission comparison:Compare the reading level of the current user's user group with the reading level of the content.

For example, in the template of the document detail page{模型table}/detail.htmlyou can write the judgment logic in this way:

{# 假设您的AnQiCMS已将当前登录用户的信息(如ID、GroupId)传递到模板中的 user 对象 #}
{% if user.IsLoggedIn %} {# 判断用户是否已登录 #}
    {% userGroupDetail currentUserGroup with id=user.GroupId %} {# 获取当前用户的用户组详情 #}
    {% archiveDetail currentArchive with id=archive.Id %} {# 获取当前文档的详细信息 #}

    {# 比较用户组的等级与内容的阅读等级。通常,用户组等级 >= 内容阅读等级才允许访问 #}
    {% if currentUserGroup.Level >= currentArchive.ReadLevel %}
        {# 用户拥有足够权限,显示完整内容 #}
        <div class="full-vip-content">
            <h1>{{ currentArchive.Title }}</h1>
            {{ currentArchive.Content|safe }} {# 使用safe过滤器以安全地显示HTML内容 #}
        </div>
    {% else %}
        {# 用户已登录但权限不足,显示升级提示 #}
        <div class="access-denied-vip">
            <p>您目前的会员等级不足以访问此专属内容。</p>
            <p>请 <a href="/upgrade-vip">升级您的VIP等级</a> 以获得完整体验!</p>
            {# 可以选择性地显示部分内容预览,例如文档简介 #}
            <p class="content-teaser">{{ currentArchive.Description }}</p>
        </div>
    {% endif %}
{% else %}
    {# 用户未登录,显示登录或注册提示 #}
    <div class="login-required-vip">
        <p>此内容为VIP专属,请先 <a href="/login">登录</a> 或 <a href="/register">注册</a> 成为会员。</p>
        {# 同样,可以显示内容的简介作为预览 #}
        <p class="content-teaser">{{ archive.Description }}</p>
    </div>
{% endif %}

In this code,user.IsLoggedInUsed to determine if the user is logged in,user.GroupIdGet the user's group ID,currentUserGroup.LevelObtain the permission level of the user group,currentArchive.ReadLevelThen get the reading level of the current content. Through simpleifJudgment, the website can dynamically display content or corresponding prompt information based on the user's identity.

Summary

Through the user group management and content reading level setting of AnQiCMS, combined with the flexible judgment of the front-end template, you can easily build a multi-level, high-value member exclusive content system.This not only effectively protects the value of your original content, but also enhances users' loyalty and willingness to pay through refined operational strategies.


Common Questions (FAQ)

Q1: How can I make it so that non-VIP users see a simple prompt without any content preview?

A1:In the frontend template, for users who are not logged in or do not have sufficient permissions, you just need to remove the display of the content summary (for example, `{{ archive.}