• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Problem Overriding helperRichUserName

James

Well-known member
#1
PHP:
public static function helperRichUserName(array $user, $usernameHtml = '')
{
if(!$user['myField'] || empty($user['myField']))
{
return parent::helperRichUserName($user, $usernameHtml);
}

if (!is_array($user) && $usernameHtml === '')
{
return '';
}

if ($usernameHtml === '')
{
$usernameHtml = htmlspecialchars($user['myField']);
}

if (empty($user['user_id']))
{
$user['display_style_group_id'] = XenForo_Model_User::$defaultGuestGroupId;
}

if (isset($user['display_style_group_id']) && isset(self::$_displayStyles[$user['display_style_group_id']]))
{
$style = self::$_displayStyles[$user['display_style_group_id']];
if ($style['username_css'])
{
return '<span class="style' . $user['display_style_group_id'] . '">' . $usernameHtml . '</span>';
}
}

return $usernameHtml;
}
That's my code to override the default XenForo helperRichUserName function. This code doesn't display the rich username.

The default helperRichUserName function is:
PHP:
public static function helperRichUserName(array $user, $usernameHtml = '')
{
if (!is_array($user) || (!isset($user['username']) && $usernameHtml === ''))
{
return '';
}

if ($usernameHtml === '')
{
$usernameHtml = htmlspecialchars($user['username']);
}

if (empty($user['user_id']))
{
$user['display_style_group_id'] = XenForo_Model_User::$defaultGuestGroupId;
}

if (isset($user['display_style_group_id']) && isset(self::$_displayStyles[$user['display_style_group_id']]))
{
$style = self::$_displayStyles[$user['display_style_group_id']];
if ($style['username_css'])
{
return '<span class="style' . $user['display_style_group_id'] . '">' . $usernameHtml . '</span>';
}
}

return $usernameHtml;
}
So there's not really much difference.

Can anyone shed any light on this?