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

**URL:** https://meta.discourse.org/t/how-to-make-only-a-group-of-users-can-send-messages-to-staff/153324
**Category:** Support
**Created:** [30 במאי,‏ 2020,‏ 6:28pm UTC](https://meta.discourse.org/t/how-to-make-only-a-group-of-users-can-send-messages-to-staff/153324 "2020-05-30T18:28:45Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![wyudong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wyudong/32/180747_2.png) [@wyudong](https://meta.discourse.org/u/wyudong)
#### Post date: [30 במאי,‏ 2020,‏ 6:28pm UTC](https://meta.discourse.org/t/how-to-make-only-a-group-of-users-can-send-messages-to-staff/153324/1 "2020-05-30T18:28:45Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [30 במאי,‏ 2020,‏ 6:38pm UTC](https://meta.discourse.org/t/how-to-make-only-a-group-of-users-can-send-messages-to-staff/153324/2 "2020-05-30T18:38:21Z")

</div>

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](https://github.com/pfaffman/discourse-allow-pm-to-staff)

---

<div class="post-metadata">

### Author: ![wyudong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wyudong/32/180747_2.png) [@wyudong](https://meta.discourse.org/u/wyudong)
#### Post date: [30 במאי,‏ 2020,‏ 6:41pm UTC](https://meta.discourse.org/t/how-to-make-only-a-group-of-users-can-send-messages-to-staff/153324/3 "2020-05-30T18:41:23Z")

</div>

Thanks! I will try your plugin.

---

<div class="post-metadata">

### Author: ![wyudong](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/wyudong/32/180747_2.png) [@wyudong](https://meta.discourse.org/u/wyudong)
#### Post date: [30 במאי,‏ 2020,‏ 7:44pm UTC](https://meta.discourse.org/t/how-to-make-only-a-group-of-users-can-send-messages-to-staff/153324/4 "2020-05-30T19:44:40Z")

</div>

@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.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [30 במאי,‏ 2020,‏ 9:11pm UTC](https://meta.discourse.org/t/how-to-make-only-a-group-of-users-can-send-messages-to-staff/153324/5 "2020-05-30T21:11:39Z")

</div>

See [Beginner’s Guide to Creating Discourse Plugins - Part 1](https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins-part-1/30515)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [29 ביוני,‏ 2020,‏ 9:24pm UTC](https://meta.discourse.org/t/how-to-make-only-a-group-of-users-can-send-messages-to-staff/153324/6 "2020-06-29T21:24:40Z")

</div>

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