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

XF 1.5 Help with inserting HTML after usernames

#1
Hey,

I was looking to add a verification system to a forum, where people who have linked their in-game accounts should get a 'tick' after their username. I was wanting to find a way to append HTML to everywhere the username is rendered with its custom styles applied (not just raw text). I found the helper userTitle and was hoping that would be of help, but I can't find the helper anywhere. Are you able to provide me a little bit of guidance? Would you target the helper as I'm trying to? Do you know where its PHP resides?

Thanks so much in advance!
- Harry
 
#2
Hey,

I was looking to add a verification system to a forum, where people who have linked their in-game accounts should get a 'tick' after their username. I was wanting to find a way to append HTML to everywhere the username is rendered with its custom styles applied (not just raw text). I found the helper userTitle and was hoping that would be of help, but I can't find the helper anywhere. Are you able to provide me a little bit of guidance? Would you target the helper as I'm trying to? Do you know where its PHP resides?

Thanks so much in advance!
- Harry
I think you should extend helperUserNameHtml function in library\XenForo\Template\Helper\Core.php like it:

PHP:
if ($user['some_field_to_check'])
{
    $attributes['class'] .= 'someIconClass'; // Add in string end needed class
}
// Next line is not changed.
$class = (empty($attributes['class']) ? '' : ' ' . htmlspecialchars($attributes['class']));

//End of this function will:
return "<a{$href} class=\"username{$class}\" dir=\"auto\"{$attribs}>{$username}</a>";