다른 카테고리에서 주제를 이동하는 것을 방지

I’m looking for an option to disable this feature as it may cause some complexity in managing threads when you have different moderators teams for different categories and suddenly they find themselves with a big or controversial thread in their category without prior notice.

I’ve read here Access rights for moving a topic to another category but it says that this is something that only Trust Level 3 should be able to do. I’ve a test environment in which a Trust Level 2 user was able to do that.

I tried to enable the “disable editing after staff edit a post” but it didn’t seem to affect the ability to change category for a thread.

Am I missing something here? I probably am :smiley:

테스트를 해야 할 것 같습니다. 카테고리 그룹 모드가 편집이나 이동 명령을 통해 주제를 이동할 수 있을 수도 있습니다.

Customization > Plugin 커스텀 신뢰 수준도 살펴보는 것이 좋습니다.

I checked that and will take it into consideration but I’ll try first to create a simple component that hide that select for editing except for staff.

I prefer plugins that does simple things :slight_smile:

@Canapin provided me code to hide like button from groups not within a specified groups.

It may give you a good baseline to work from.

fixed link

Thank you so much @Heliosurge (and the ubiquitous @Canapin :stuck_out_tongue: ) I was just thinking of where I could look for a similar plugin to use as example :slight_smile:

Your quite welcome! The team and this community are awesome in my xp. :clinking_beer_mugs::smiling_face_with_sunglasses::+1:

I gave it a look, it’s a good MVP but the community I look for is quite tech savvy and it would be better if the DOM would entirely skip drawing that component instead of simply hiding it from view.

Would that require a plugin or is it something I could achieve anyway with a component?

What I need to do, roughly is basically determine if the HTML for that select is generated or not, based on the role.

I’m pretty sure a component would suffice.

I’m not a coder.

To hide the category selector when you edit the first post (from the edit post action, not the edit title), this works:

<script type="text/discourse-plugin" version="1.6.0">
    let currentUser = api.getCurrentUser();
    api.modifyClass("component:composer-title", {
      pluginId: "PreventCategoryChange",
      didInsertElement: function() {
        if(currentUser.trust_level == 1) {
            let categoryInput = document.getElementsByClassName('category-input')[0];
            let miniTagChoser = document.getElementsByClassName('mini-tag-chooser')[0];
            if(categoryInput != null) {
                categoryInput.remove();
                if(miniTagChoser != null) {
                    miniTagChoser.style.marginLeft = '0';
                }
            }
        }
      }
    });
</script>

chrome_NTAAc37JXB

I used the trust level, but I think you can manage to check the user group instead, it’s all in the currentUser object.

I don’t know how to dynamically remove the category selector when we edit the title.
Maybe you can figure it out from the files that seems related:

discourse/app/assets/javascripts/discourse/app/templates/topic.hbs at 53695e7d29e718041fa53bf4fef21e02354a4088 · discourse/discourse · GitHub

discourse/app/assets/javascripts/discourse/app/controllers/topic.js at 8fc11215e195a5bd8db130f52717c126c119432b · discourse/discourse · GitHub

Thank you so much @Canapin

I’ll need to add something also for the edit from the title but this definitely help already :slight_smile:

When it’s done, I’ll post it in the theme components section here so other may use it :wink:

This discourse/app/assets/javascripts/discourse/app/templates/topic.hbs at 53695e7d29e718041fa53bf4fef21e02354a4088 · discourse/discourse · GitHub

seems to be the right handle to access, now if someone knows how to interact with it via theme component… :stuck_out_tongue:

For the love of the gods I can’t find a hook to detect when the title editing is being triggered. Anyone knows what I could listen for?

The hiding of category change when editing the first message of a topic works, it detects only when being in editing mode and all.

잠 못 드는 좋은 친구 덕분에 올바른 훅을 어디에서 찾아야 하는지 알아냈습니다 :stuck_out_tongue:

바로 이거예요. 폼의 시각적 요소도 조정하고, 카테고리 편집 접근이 허용되는 최소 신뢰 수준을 선택할 수 있게 해줍니다 (디스커스 기본 설정과 일치하도록 기본 신뢰 수준 0으로 설정됨)

이제 Customization > Plugin 섹션에서 새 주제를 만들러 가볼게요.

처음에 올바른 방향으로 이끌어주셔서 정말 감사합니다 @Canapin :heart_eyes:

코드를 확인해 보았는데, 정말 잘하셨네요 :+1:

제가 여러분에게서 더 많이 배운 것 같습니다!

참고로, 여러분이 만든 것은 #customization:theme-component이지 #customization:plugin이 아닙니다 :slight_smile:

Just to note, a TL3 and TL4 can recategorise any topic as long as trusted users can edit others is enabled. A TL0/1/2 should only be able to do it on their own topic, and only within their editing period [1]. If you lock the first post using the post wrench then that should also stop the category (and title and tags) from being edited.

I’m not 100% sure I’m following your use case, but I’m glad you found a solution. :slightly_smiling_face::+1:


  1. set by post edit time limit for TL0 and TL1 and tl2 post edit time limit for TL2 and TL3 ↩︎

Ah, yes, I wasn’t aware of this option:

It prevents any further modification (except being deleted) even from a category moderator.

But a first post lock can’t be automated from a topic timer nor an automated task.

Yes, I was aware of it.

However, my intent was to prevent the moderators to have to deal with several occurrence of category hopping which may lead to complication in the moderation when a topic is first in a category, then move into another etc etc

I think it would be important to add since it’s a theme component, a user can circumvent these limitations by injecting javascript (I think) or enabling the safe mode if it’s available for them (see enable safe mode setting).

You need a plugin if you want a more secure way to do it.

Yes, that’s why I was looking into plugins as well but for a first version, a component is enough.