Prevent users from moving topics in other categories

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