# Come disattivare i messaggi privati tra utenti non staff?

**URL:** https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436
**Category:** Support
**Created:** [26 Luglio 2015, 2:25am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436 "2015-07-26T02:25:12Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Ricardo\_Viteri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ricardo_viteri/32/65442_2.png) [@Ricardo\_Viteri](https://meta.discourse.org/u/Ricardo_Viteri)
#### Post date: [26 Luglio 2015, 2:25am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/1 "2015-07-26T02:25:12Z")

</div>

Hello,

Is it possible to disable private messages between non Admin or moderator users?

Thanks,

Ricardo

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [26 Luglio 2015, 6:01am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/5 "2015-07-26T06:01:25Z")

</div>

No need for all this conversation, there is a single Boolean in site settings that does what you want. “Enable private messages”. Seems obvious enough to me..

---

<div class="post-metadata">

### Author: ![Ricardo\_Viteri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ricardo_viteri/32/65442_2.png) [@Ricardo\_Viteri](https://meta.discourse.org/u/Ricardo_Viteri)
#### Post date: [27 Luglio 2015, 2:35am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/6 "2015-07-27T02:35:50Z")

</div>

But this would also disable private messages between a moderator / admin and user?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [27 Luglio 2015, 2:38am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/7 "2015-07-27T02:38:23Z")

</div>

Nope, it will not. Staff are always immune from these kinds of restrictions.

---

<div class="post-metadata">

### Author: ![Ricardo\_Viteri](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ricardo_viteri/32/65442_2.png) [@Ricardo\_Viteri](https://meta.discourse.org/u/Ricardo_Viteri)
#### Post date: [27 Luglio 2015, 2:44am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/8 "2015-07-27T02:44:00Z")

</div>

This is Awesome! Thanks.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [27 Luglio 2015, 3:02am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/9 "2015-07-27T03:02:03Z")

</div>

I should change the copy for this setting to be more clear…

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [27 Luglio 2015, 3:34am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/10 "2015-07-27T03:34:08Z")

</div>

> [@codinghorror](#):
>
> Staff are always immune from these kinds of restrictions.

Hmmmm, I’m missing seeing that in the guardian.rb file.

```plaintext
  def can_send_private_message?(target)
    (target.is_a?(Group) || target.is_a?(User)) &&
    # User is authenticated
    authenticated? &&
    # Can't send message to yourself
    is_not_me?(target) &&
    # Have to be a basic level at least
    @user.has_trust_level?(TrustLevel[1]) &&
    # PMs are enabled
    (SiteSetting.enable_private_messages ||
      @user.username == SiteSetting.site_contact_username ||
      @user == Discourse.system_user) &&
    # Can't send PMs to suspended users
    (is_staff? || target.is_a?(Group) || !target.suspended?)
  end

```

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [27 Luglio 2015, 4:51am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/11 "2015-07-27T04:51:00Z")

</div>

I don’t want to over-step, especially since I don’t know if the changes would have ramifications elsewhere and only did minor testing. .  
But as best as I can tell, this seems to work more in tune with the stated intent

```diff
  def can_send_private_message?(target)
    (target.is_a?(Group) || target.is_a?(User)) &&
    # User is authenticated
    authenticated? &&
    # Can't send message to yourself
    is_not_me?(target) &&
    # Have to be a basic level at least
- @user.has_trust_level?(TrustLevel[1]) &&
+ (@user.has_trust_level?(TrustLevel[1]) || is_staff?) &&
    # PMs are enabled
    (SiteSetting.enable_private_messages ||
      @user.username == SiteSetting.site_contact_username ||
- @user == Discourse.system_user ) &&
+ @user == Discourse.system_user || 
+ is_staff?) &&
    # Can't send PMs to suspended users
    (is_staff? || target.is_a?(Group) || !target.suspended?)
  end

```

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [22 Febbraio 2017, 6:18am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/12 "2017-02-22T06:18:17Z")

</div>

You were right about the bug here @Mittineague. Should be fixed now:

[https://github.com/discourse/discourse/commit/b32f33b3f06602e1d742920b8024949aaaa647b2](https://github.com/discourse/discourse/commit/b32f33b3f06602e1d742920b8024949aaaa647b2)

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [21 Marzo 2017, 6:53am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/13 "2017-03-21T06:53:20Z")

</div>



---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [20 Settembre 2024, 2:27am UTC](https://meta.discourse.org/t/how-do-disable-private-messages-between-non-staff-users/31436/14 "2024-09-20T02:27:24Z")

</div>


