XF 1.5 Help with inserting HTML after usernames

Nikolov69

Member
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
 
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>";
 
Top Bottom