# Add user's groups as a class to messages in chat

**URL:** https://meta.discourse.org/t/add-users-groups-as-a-class-to-messages-in-chat/250092
**Category:** Feature
**Tags:** chat
**Created:** [December 29, 2022, 6:57am UTC](https://meta.discourse.org/t/add-users-groups-as-a-class-to-messages-in-chat/250092 "2022-12-29T06:57:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![hiddenseal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hiddenseal/32/284273_2.png) [@hiddenseal](https://meta.discourse.org/u/hiddenseal)
#### Post date: [December 29, 2022, 6:57am UTC](https://meta.discourse.org/t/add-users-groups-as-a-class-to-messages-in-chat/250092/1 "2022-12-29T06:57:02Z")

</div>

Currently, the HTML containing username or full name of a poster on any regular post is augmented with the information about groups of a user as classes.

```plaintext
<span class="first full-name staff admin group--GROUPNAME"><a href="/u/USER" data-user-card="USER" class="">Full Name</a></span>

```

I believe the [code responsible for this behavior is here](https://github.com/discourse/discourse/blob/b1e08364ef04e8befcf0c7357cd586f72cc376b2/app/assets/javascripts/discourse/app/widgets/poster-name.js)

Wouldn’t it be good if a similar thing was made for chat messages? It may be beneficial to color code certain groups so that some (e.g. from staff) messages are distinguished from others…

I.e. if

```plaintext
<span class="chat-message-info __username__ name">Full Name</span>

```

was

```plaintext
<span class="chat-message-info __username__ name staff admin group--GROUPNAME">Full Name</span>

```

It seems like the chat messages don’t have a similar .js file pushing attributes and [the classes only come from this file.](https://github.com/discourse/discourse/blob/9f0a095405397ef4a257764ae7ae95882e8ea215/plugins/chat/assets/javascripts/discourse/components/chat-message-info.hbs)

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [February 16, 2023, 4:19pm UTC](https://meta.discourse.org/t/add-users-groups-as-a-class-to-messages-in-chat/250092/3 "2023-02-16T16:19:13Z")

</div>

I just pushed a change which should do it:

[https://github.com/discourse/discourse/pull/20322](https://github.com/discourse/discourse/pull/20322)

Let me know how it goes for you 👍

---

<div class="post-metadata">

### Author: ![hiddenseal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/hiddenseal/32/284273_2.png) [@hiddenseal](https://meta.discourse.org/u/hiddenseal)
#### Post date: [February 18, 2023, 9:39pm UTC](https://meta.discourse.org/t/add-users-groups-as-a-class-to-messages-in-chat/250092/4 "2023-02-18T21:39:42Z")

</div>

looks good, thank you!

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [February 22, 2023, 9:40pm UTC](https://meta.discourse.org/t/add-users-groups-as-a-class-to-messages-in-chat/250092/5 "2023-02-22T21:40:13Z")

</div>

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