legacy-knowledge-base
公開されました 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 supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

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

legacy-article

learn-legacy-article-disclaimer-text

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