# User mention limit: clarify the error message?

**URL:** https://meta.discourse.org/t/user-mention-limit-clarify-the-error-message/231649
**Category:** UX
**Tags:** mentions
**Created:** [July 1, 2022, 7:51am UTC](https://meta.discourse.org/t/user-mention-limit-clarify-the-error-message/231649 "2022-07-01T07:51:12Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![yrodiere](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yrodiere/32/265551_2.png) [@yrodiere](https://meta.discourse.org/u/yrodiere)
#### Post date: [July 1, 2022, 7:51am UTC](https://meta.discourse.org/t/user-mention-limit-clarify-the-error-message/231649/1 "2022-07-01T07:51:12Z")

</div>

Hello,

There’s a feature in Discourse that limits the number of user mentions in messages, and limits it even more for “new” users (trust level 0).

If you don’t know what I mean, here is the implementation in the source code of Discourse:

> <https://github.com/discourse/discourse/blob/9957929a151c30d77316b11a954fc2ed8509eb0e/lib/validators/post_validator.rb#L59-L67>

That’s a fine feature, but as it happens, we’ve had a few users hit that limit by mistake and being confused. The thing is, they did not _mean_ to mention a user. They just “forgot” (or didn’t know how) to format a snippet of code included in their message, and that snippet being Java code, it included annotations, which start with `@` and get interpreted as user mentions.

An example of such code:

```java
public class MyCode {

@NotNull 
private String foo;

@NotNull 
private String bar;

@NotNull 
private String foobar;

}

```

The error message is simply this:

```plaintext
Sorry, new users can only mention 2 users in a post

```

You can imagine that a user who is unfamiliar with how to format code in markdown may also be unfamiliar with what a user mention is, and even if they’re familiar with it, they may not understand that what they meant as a Java annotation was interpreted as a user mention.

So… maybe the user experience of that feature can be improved?

We could talk of Discourse automatically detecting source code and suggesting to format it, or highlighting the parts of the message whose validation failed, but either of these solutions would probably require a lot of effort.

I was thinking of just expanding the error message to explain what a user mention is, and maybe give some advice?

So at least this:

```plaintext
Sorry, new users can only mention 2 users in a post.
User mentions are words prefixed with `@`, for example `@johnsmith`.

```

And maybe even this:

```plaintext
Sorry, new users can only mention 2 users in a post.
User mentions are words prefixed with `@`, for example `@johnsmith`.
If your post includes source code, make sure to surround it with backticks to avoid having parts of your code interpreted as user mentions; see <insert some links to documentation about formatting code on discourse>.

```

Thoughts, opinions? Should I send a pull request? I’m afraid I can only update the English and French locales, though.

For reference, some examples of confused users:

- [Sorry, new users can only mention 2 users in a post - Site Feedback - Hibernate](https://discourse.hibernate.org/t/sorry-new-users-can-only-mention-2-users-in-a-post/3933)
- [Hibernate used with H2 - In Memory DB needed - #4 by Nils\_Tolleshaug - Miscellaneous - Hibernate](https://discourse.hibernate.org/t/hibernate-used-with-h2-in-memory-db-needed/6424/4)

---

<div class="post-metadata">

### Author: ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)
#### Post date: [July 1, 2022, 8:02am UTC](https://meta.discourse.org/t/user-mention-limit-clarify-the-error-message/231649/2 "2022-07-01T08:02:43Z")

</div>

> [@yrodiere](#):
>
> We could talk of Discourse automatically detecting source code and suggesting to format it

There is a #Customization > Theme component doing that

> [@Unformatted Code Detector](https://meta.discourse.org/t/unformatted-code-detector-theme-component/112773):
>
> discourse2Summary Unformatted Code Detector detects unformatted code and gives a warning before posting.eyeglassesPreview [Preview on Discourse Theme Creator](https://discourse.theme-creator.io/theme/Discourse/unformatted-code-detector)hammer_and_wrenchRepository Link [https://github.com/discourse/unformatted-code-detector](https://github.com/discourse/unformatted-code-detector)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Install this theme component Features Users posting unformatted code will see a warning message instructing them how to format it correctly…

---

<div class="post-metadata">

### Author: ![yrodiere](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yrodiere/32/265551_2.png) [@yrodiere](https://meta.discourse.org/u/yrodiere)
#### Post date: [July 1, 2022, 8:17am UTC](https://meta.discourse.org/t/user-mention-limit-clarify-the-error-message/231649/3 "2022-07-01T08:17:17Z")

</div>

> [@Moin](#):
>
> There is a #Customization > Theme component doing that

Thanks! That’s great, I didn’t know it existed. Hopefully it will prevent users from getting in this situation in the first place 🙂

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [July 1, 2022, 8:36am UTC](https://meta.discourse.org/t/user-mention-limit-clarify-the-error-message/231649/4 "2022-07-01T08:36:03Z")

</div>

> [@yrodiere](#):
>
> `Sorry, new users can only mention 2 users in a post`

If it still remains an issue even with the Unformatted Code Detector theme component, you can also change the text of this message for your site from the `/admin/customize/site_texts` page, as well as tweaking the `newuser max mentions per post` admin setting itself if it’s causing more snags than it’s solving. 🙂

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/2/0/c20c2a1d726b8d9b3ce230b4d78581756aebffb2.png)

 ![image](https://global.discourse-cdn.com/meta/original/4X/9/f/3/9f3980e619b80088952e26d37465e2e8eb24f82a.png)

---

<div class="post-metadata">

### Author: ![yrodiere](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/yrodiere/32/265551_2.png) [@yrodiere](https://meta.discourse.org/u/yrodiere)
#### Post date: [July 1, 2022, 9:10am UTC](https://meta.discourse.org/t/user-mention-limit-clarify-the-error-message/231649/5 "2022-07-01T09:10:24Z")

</div>

Awesome, I didn’t know I could customize just any text appearing in Discourse. Done!

Then I suppose there’s really no need for a pull request 🙂
