تمكين المكونات وفقًا لمجموعات المستخدمين أو مستويات الثقة

هل من الممكن إظهار مكونات معينة بناءً على مستويات الثقة، أو على سبيل المثال، إذا كان المستخدمون ينتمون إلى مجموعة معينة؟

لدي بعض ميزات الجافا سكريبت و CSS المخصصة التي قمت بإنشائها لمنصتي Discourse، لكنني أود أن تكون قابلة للاستخدام والرؤية فقط من قبل مستخدمين معينين ينتمون إلى مجموعات محددة. هل من الممكن القيام بذلك دون الحاجة إلى كتابة إضافة (plugin)؟

شكرًا لكم على إجاباتكم.

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.

إعجابَين (2)

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

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.