Help > Forum > 主题和外观 > 更改特定用户组的帖子的背景颜色

更改特定用户组的帖子的背景颜色

您可以为来自特定用户组的帖子设置不同的背景颜色。例如,您可以将来自 “常规” 用户组中用户的帖子的背景颜色设为金色,而来自其他用户组的帖子仍使用默认颜色。请遵循以下指示:

  1. 登录您的Website Toolbox账户。
  2. 点击 整合 链接。
  3. 点击 HTML 链接。
  4. 复制下面的 HTML 代码并将其粘贴到 论坛头标签 HTML 代码 文本框:
  5. <style>e
    .post-body.wt-general-post {
        background-color: #f5efd7;
    }
    .post-author.wt-general-post .post-arrow {
        border-right-color: #f5efd7;
    }
    @media (max-width: 720px) {
        .post-author.wt-general-post {
            background-color: #f5efd7;
        }
    }
    </style>
    <script>
    var groupCustomClass = {
            'GENERAL-GROUP-ID' : 'wt-general-post'
        };
        function changePostBackgroundColor() {
            if(jQ('.post-body-wrapper').length) {
                jQ('.post-body-wrapper .post-body-author .display_name a').each(function( index ) {
                    var postAutherDivId;
                    var postDivId = jQ(this).closest('.post-body').attr('id');
                    if(typeof postDivId != "undefined" && postDivId != "" && postDivId.indexOf('post_list_') > -1) {
                        postAutherDivId = postDivId.replace(/post_list_/g,"post_row_");
                    }
                    if(typeof postAutherDivId != "undefined" && postAutherDivId != "") {
                        var className = jQ(this).attr('class');
                        var classArray = className.split(' ');
                        jQ.each(classArray, function(index, value) {
                          if(typeof value != "undefined" && value != "" && value.indexOf('usergroup') > -1) {
                            var groupid = value.replace(/usergroup/g,"");
                            console.log("=groupid="+groupid+"=postAutherDivId="+postAutherDivId+"=class="+groupCustomClass[groupid]+"=end=");
                            if(typeof groupid != "undefined" && groupid != "" && groupid) {
                                jQ('#'+postDivId+'').addClass(groupCustomClass[groupid]);
                                jQ('#'+postAutherDivId+' .post-author').addClass(groupCustomClass[groupid]);
                                return false;
                            }
                          }
                        });
                    }
                });
            }
        }
        // Change post back ground color when DOM loaded.
        window.addEventListener("DOMContentLoaded", function(){
            changePostBackgroundColor();
        });
        // Change post back ground color when create a post.
        document.addEventListener('replyPosted', function(event) {
            changePostBackgroundColor();
        });
        // Change post back ground color when edit a post.
        document.addEventListener('postEdited', function(event) {
            changePostBackgroundColor();
        });
    </script>
    
  6. 更改颜色代码 #f5efd7 在上面的代码中,所有三个地方都需要一个。#f5efd7 代表蓝色。点击 十六进制代码 获取不同颜色的颜色代码。
  7. 检索 用户组的 ID.
  8. 替换文本 通用组编号 在上面的代码中,并在步骤 6 中检索到的用户组 ID。
  9. 保存 你的改变。

以下是突出显示的帖子的示例:


If you still need help, please contact us.