/// <summary> /// Gets the name of the user's status. /// </summary> /// <param name="userId">The user ID, or <c>null</c> for an anonymous user.</param> /// <returns>The name of the status, or <c>null</c> for an anonymous user or user without a status</returns> protected string GetUserStatusName(int?userId) { try { if (userId.HasValue) { var statusId = UserStatusInfo.LoadUserStatus(this.PortalSettings, userId.Value); if (statusId.HasValue) { return(UserStatus.LoadStatus(statusId.Value).Status); } } } catch (NullReferenceException) { // thrown from LoadUserStatus if user doesn't exist (has been deleted after applying). BD } return(null); }