Customizing the format of usernames

If you want to customize how the system displays usernames in the administration interface, modify the GetFormattedUsername method in ~/AppCode/CMS/Functions.cs.

Example

Usernames are displayed in the <full name> (<user name>) (e.g. Abigail Woodwarth (Abi)) format in some parts of the system, for example when editing pages in the Pages application on the Properties -> General tab.

The following code example shows how to modify the method to get usernames in format <user name> [<full name>] (e.g. Abi [Abigail Woodwarth]):




using CMS.Membership;
using CMS.Helpers;

...

public static string GetFormattedUserName(string username, string fullname, bool isLiveSite)
{
    username = UserInfoProvider.TrimSitePrefix(username);

    if (!String.IsNullOrEmpty(DataHelper.GetNotEmpty(fullname, "").Trim()))
    {
        return String.Format("{1} [{0}]", fullname, username);
    }
    else
    {
        return username;
    }
}