Forum Discussion
There isn't a config option to do this for message posts but you could customize your message page to show first name and last name.
You would need to create a custom component that pulled the user's first/last name from their profile setting then add it to the Forum Message page. Before you do that - I can help you through the technical steps if you need it - you should think about a couple of things.
1. Do your users have first name and last name filled out? A lot users do not enter personally identifiable information in their community accounts.
2. How will your users feel if you start displaying their name? Do you want to add an option for turning this off or having users opt in before this is displayed?
There is a lot of back and forth on "real names" in comments and posts. Make sure you know what you are getting into :)
- cgmcconnell14 years agoExpert
Hey Kaela,
Thanks for such a quick response! In regards to your questions, thanks for bringing up those points, as they relate to my community:
1. Foruntately we have the first and last name for all of our users as we use SSO tied to our existing registration process (which requires a name and is usually accurate). Additionally, half of our user base are our interntal customers which have 100% accurate information.
2. That's an interesting thought but I feel pretty comfortable switching it on as, by default, we show first and last name on their user profile page.
Also, I'm assuming the custom component could be placed everywhere a username is used?
Thanks,
Colin- KaelaC14 years agoLithium Alumni (Retired)
Hi Colin,
Sorry for the late reply. There are two parts to this that you will need to do. The first is create a custom component that pulls the user's first and last name. Like Adam said, you can use env.context.message.author to figure out who the message author is.
<#assign allowed=rest("/users/id/${env.context.message.author?c}/profiles/name/name_first/allowed").value /> <#if allowed?trim == "true"> <#assign first_name= rest("/users/id/${env.context.message.author?c?c}/profiles/name/name_first").value!"" /> <#assign last_name= rest("/users/id/${env.context.message.author?c?c}/profiles/name/name_last").value!"" /> </#if> ${first_name} ${last_name}
The first part of this look to see if the current user has permission to see the author's profile information. Next, it amakes rest calls to get that information. Lastly, it displays the first and last names.
The second part is to add this new component to the ForumMessage page in studio. I'm having a hard time finding it myself so you may need to ask support to do that (or maybe I'm just going blind).
- cgmcconnell14 years agoExpert
Hi Kaela,
I tried using this in studio but I am being given an error message, essentially what I did was:
1. Create a new custom content module and pasted in the code you outlined above,
2. Adding a custom component on the forum message page.
When I view a forum message, I'm shown an error message, this bit below is a segment of that:
Expression first_name is undefined on line 1, column 3 in preview. The problematic instruction: ---------- ==> ${first_name} [on line 1, column 1 in preview] ----------
Do you have any ideas for fixing this?
Thanks,
Colin
- AdamN14 years agoKhoros Oracle
Hi Colin,
It really depends on how you construct the component. There are a few different context objects you can make use of with freemarker:
- env.context.message.author - if the component is within the context of a message, this will give you the author of the message.
- page.context.user - if you place the component on the ViewProfilePage, this will give you the user whose profile page is currently being displayed
- user.id - On any page, this will give you the id of the user viewing the page
So you could very well construct a single component that handled a bunch of different cases. However, depending on exactly what you're trying to accomplish, it might be easier to just have separate, specific-use components.
I hope this helps!
Related Content
- 6 years ago