Legacy Knowledge Base
Published Jun. 30, 2025

Author information that is displayed in the forum posts

Written By

Jose Bodega

How To articles are not official guidelines or officially supporteddocumentation. They are community-contributed content and may not alwaysreflect the latest updates to Liferay DXP. We welcome your feedback toimprove How to articles!

While we make every effort to ensure this Knowledge Base is accurate, itmay not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with anyfeedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack"publication program, made available for informational purposes. Articlesin this program were published without a requirement for independentediting or verification and are provided "as is" withoutguarantee.

Before using any information from this article, independently verify itssuitability for your situation and project.

Issue

  • When users send messages or create threads in the discussion forum, certain information about them (name + surname) is displayed. This article covers the need to change this behavior through a customization and display the user's screen name instead of their full name.

Environment

  • 2023.Q4

Resolution

  • To change the behavior, a fragment type customization would need to be implemented.(https://help.liferay.com/hc/es/articles/360017881152-JSP-Overrides-Using-OSGi-Fragments).
  • The JSP to be modified would be the following retrieving the User object associated with the userId available in that JSP through the UserLocalServiceUtil API and subsequently obtaining the screenName. -> Code github
    <%
    String messageUserName = "anonymous";
    if (thread.getLastPostByUserId() != 0) {
    messageUserName = HtmlUtil.escape(PortalUtil.getUserName(thread.getLastPostByUserId(), StringPool.BLANK));


    if (Validator.isNull(messageUserName)) {
    MBMessage lastThreadMessage = MBMessageLocalServiceUtil.getLastThreadMessage(thread.getThreadId(), thread.getStatus());


    messageUserName = HtmlUtil.escape(PortalUtil.getUserName(lastThreadMessage.getUserId(), lastThreadMessage.getUserName()));
    }
    }


    Date lastPostDate = thread.getLastPostDate();


    String lastPostDateDescription = LanguageUtil.getTimeDescription(request, System.currentTimeMillis() - lastPostDate.getTime(), true);
    %>


    <p class="list-group-subtext">
    <liferay-ui:message arguments="<%= new String[] {messageUserName, lastPostDateDescription} %>" key="x-replied-x-ago" />
    </p>

NOTE: The following resolution requires customization and should only be implemented at the discretion of your team. Liferay Support will not be able to assist with designing or implementing customizations.

Did this article resolve your issue ?

Legacy Knowledge Base