Discourse Show Fullname in Mentions

Install this theme component

A theme component to display the full name instead of usernames in @mentions.

This theme component loads the full name of the user and display @fullname instead of @username in mentions.

This component works by simply replacing the username with the name of the user (if available) when displaying the posts. Nothing changes while editing. You still tag @username like always in the composer.

It also adds the class .mention-fullname to the a.mention anchor element if you wish the style full name mentions in a distinct way.

Displaying the card when clicking in the @fullname mentions remains fully functional.

Use case:

Imagine a Discourse instance where every username name follows the pattern X9999999 (one letter and seven numbers). Now imagine there are 100k users registered.

Not very friendly, right? Unfortunately, this is a very real scenario and not an imaginary one. The Discourse instance is bonded to SSO and all usernames follow corporate policy.

It’s much better in this case to read @John Doe instead of @X9999999.

Settings:

  • show_fullname_in_mentions: If enabled @mentions will show the @fullname instead of the @username
16 Likes

Hello SĂ©rgio, thanks for the theme component!

I tried it but after experimenting I see it create some inconsistency UX-wise.

Here’s what happens : I got this user whom username is “oli44” and fullname “Henri Oliver”. With your theme component it now displays “Henri Oliver” which is great adds better context. But then, let’s say then I’m another user who doesn’t know that “Henri Oliver” goes by the username “oli44” then how do I mention him in my post?

I’m gonna search for “Henri Oliver” and I will see in deed “oli44” but how can I know it’s the actual person?

For that reason, as it is I’m finally not enabling it for the moment. Do you know eventually another theme component/plugin which would solve that problem? I tried to look for such but couldn’t find.

Or maybe there’s a way your theme component could still show the username (for ex: @Henri Oliver (oli44)) so when I need to mention that person I know what to look for(?)

Thanks anyway for this great addition

3 Likes

You just type @ followed by Henri Oliver. After confirming, @+username will be inserted into your post.

When searching, both the username and the full name are displayed.
Where is the problem?

You can customize the rendering in a fork easily:

1 Like

I see two issues:

There will be one ajax request per mention to the server.
Could this lead to throttling in pages with a lot of usernames (like user supplied user directories)?

The cached username to full-name translation will not recognize changes in full-name. How long does this cache live?

I wonder if the needed information (username → fullname) could be provided via a companion plugin, which would make these issues obsolete.

Since we were experiencing the expected problems, I created a plugin that provides the full names along with the mentions:

Accordingly, the ajax request was removed from the component.

I also added an option to configure the template used for rendering
mentions:

2 Likes

Were ajax requests mandatory if we wanted to stick to a theme component?

If this is the case, I invite you to create a new plugin topic, if you consider your work reliable enough to be used by others :slight_smile:

I’m not allowed to write in that category …

I don’t know. Since I’m only digging into plugin / component development, I’ve chosen to collect these two hacks, to get the desired behavior.

But maybe others like to join in to polish it.

1 Like

You have to request access on the group page :slight_smile:

https://meta.discourse.org/g/plugin_authors

1 Like

You just posted this and I just installed the original author’s plugin right as you posted. The thing is, I noticed that the original author’s plugin does not support full names for group. However, it looks like you added groups. If so, congratulations! Your plugin deserves its own thread given what you’ve enabled!

Maybe I’m not doing something right, but I enabled your theme component and plugin and I’m no longer seeing the full name in mentions.

Did you rebake your posts?

1 Like

Thanks! Now I did. Would searching groups also be possible? I have my trust_level_0 group named as everyone. If the plugin could also use the full name for the group mentions, this would be a cool way to make global trust_level_0 mentions look like an everyone mention.

It does now (you have to update the component also).

Unfortunately, the group name link will not open the group when clicked.

1 Like

Since the plugin includes the info while baking the posts. Be aware that if the user updates the full name, it won’t be updated in the post unless the post is rebaked.

I need to update a few things in this theme-component. Removing the Ajax calls is now possible if the user status is enabled.

Will try to do it soon.

2 Likes

Exactly. It should watch user and group name changes:

2 Likes

Rebaking is expensive. This can be problematic in some communities, depending on how frequently the users change their names.

Keep this in mind.

1 Like

Thanks. In our more formal school community the names will not change frequently.

In principle, the names could be added while shipping already baked content. It seems, you would prefer this path?

It works mostly. I am not sure why but even though I have trust level 0 renamed to everyone, it doesn’t apply the label to it.


Non trust-level groups all work though and display their full names.

EDIT: Ah, because the full_name column in the groups table does not hold the modified full name value of trust level groups! Checking data explorer, it is null. Hmm?

From the above picture, it seems that you changed i18n entries for trust_level_0.

Try Group.find(10).update! full_name: "TESTTEST" in rails console.

This might have side effects, considering changing full names of built-in groups is not allowed in the UI.

Indeed. I tried this, and it worked without any serious impact. Is there a way to incorporate groups without having to use the plugin and only using the theme component? That’s actually preferred for me since I don’t relish raking if I can avoid it.