Kentico CMS 7.0 Developer's Guide

Username customization

Username customization

Previous topic Next topic Mail us feedback on this topic!  

Username customization

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

If you want to customize the way usernames are displayed in the administration interface, you can do it by modifying the GetFormattedUsername method in ~/AppCode/CMS/Functions.cs. The method has four overrides and is used to retrieve usernames in the whole administration interface.

 

Example: Usernames are displayed in the <full name> (<user name>) (e.g. Abigail Woodwarth (Abi)) format in some parts of the system, e.g. in document Properties -> General -> Owner. The following code example shows how you can modify the method to get usernames in format <user name> [<full name>] (e.g. Abi [Abigail Woodwarth]):

 

[C#]

 

public static string GetFormattedUserName(string username, string fullname, bool isLiveSite)

{

  if (!String.IsNullOrEmpty(DataHelper.GetNotEmpty(fullname, "").Trim()))

   {

      return String.Format("{1} [{0}]", fullname, username);

   }

  else

   {

      return username;

   }

}