How to make only a group of users can send messages to staff

סיכום מבוסס בינה מלאכותית

The discussion revolves around restricting private messaging to staff members to only specific user groups, such as a ‘premium’ group. wyudong asks if this can be achieved via a plugin or code extension. pfaffman shares a plugin that enables private messaging to staff and confirms it can be adapted for group-specific access, though it currently fails Travis tests. wyudong expresses intent to try the plugin, and in a follow-up, asks how to debug by printing variables in a non-Docker Mac environment. pfaffman directs to a beginner’s guide on plugin development for further assistance.

The scenario is that a group of users, e.g. premium group, are allowed to send messages to staff group. Except those premium, users not in that group cannot message to staff. Is that possible to extend discourse code or write a plugin to accomplish that?

I have a plugin that allows everyone to send to staff. It should be possible to make it so that only a group can.

It’s currently failing tests on Travis. I don’t know why.

https://github.com/pfaffman/discourse-allow-pm-to-staff

Thanks! I will try your plugin.

@pfaffman I’m not familiar with ruby. Your method is rewriting can_send_private_message guardian, and I notice the plugin code is merged to current discourse code. Please correct me if I’m wrong.

One more question is how can I print some variables in my console, like console.log() in Javascript? I want check if the sender belongs to foo group and the receiver is bar group. I tried to put a variable but couldn’t find the result in the console. I’m developing on mac without docker container btw.

See Beginner’s Guide to Creating Discourse Plugins - Part 1