고정/고정 해제 버튼에 대한 접근 권한 제한 방법

header에 이 코드를 적용해 보았습니다.

document.addEventListener("DOMContentLoaded", function() {
    setTimeout(() => {
        let userTrustLevel = parseInt(Discourse.User.current().trust_level);
        
        if (userTrustLevel < 4) {
            document.querySelectorAll(".pin-topic, .unpin-topic").forEach(button => {
                button.style.pointerEvents = "none"; 
                button.style.opacity = "0.5"; 
                button.title = "You don't have permission to pin topics"; 
            });
        }
    }, 1000);  complet
});

그리고 CSS에는 다음과 같이 설정했습니다.

.d-header-icons .pin-topic, 
.d-header-icons .unpin-topic, 
.controls .pin-topic, 
.controls .unpin-topic {
    display: none !important;
}

하지만 신뢰도(trust level)가 1 또는 0인 일반 사용자는 고정(pin) 버튼을 보고 클릭할 수 있습니다.

Automatically unpin topics when the user reaches the bottom by default. 이 옵션은 꺼져 있습니다.
Automatically unpin topics when the user reaches the bottom. 이 옵션도 꺼져 있습니다.

안녕하세요, 환영합니다! :wave:

이 버튼들에 대해 말씀하시는 건가요?

CSS만으로 버튼을 숨길 수 있습니다.

먼저 이 컴포넌트를 설치하세요: CSS Classes for Current User's Groups. 이 컴포넌트는 현재 사용자의 그룹 이름(예: group-<name>)을 <body> 요소에 추가합니다.

이후 원하는 대상에 적용할 수 있습니다:

:not(.group-trust_level_4) #topic-footer-buttons .pinned-button {
  display: none;
}

또한, 토픽을 고정/고정 해제할 수 있는 여러 위치가 있습니다: