Enable components according to user groups or trust levels

Is it possible to make visible certain components according to trust levels or for example if users are in a certain group?

I have some custom javascript and css features that I made for my discourse, but I wish that they are usable and seen only by certain users that belong to certain groups. Is that possible to do without a need to write a plugin?

Thank you for your answers.

In your theme component’s javascript you have access to the current user object:

<script type="text/discourse-plugin" version="0.8">
let currentUser = api.getCurrentUser();
console.log(currentUser);
</script>

And then you can check currentUser.trust_level or currentUser.groups and enable/disable the functionality accordingly.

1 Like

Thank you very much! Will try this. I must have missed this bit of code in the documentation.