XF 2.1 Remove staff, admin, moderator classes from username link easily?

Tumpe

Member
Every username link for moderator / staff on XF2 has a span that has classes referring to the user group, i.e.

<span class="username--moderator username--admin">

For regular users that don't have any custom css declarations the span and classes doesn't exist. Boards that have "anonymous" moderators and staff, this is an issue. Even though it's only visible in html source, it's enough.

I found that I can modify that in Templater.php (fnUsernameClasses), but is there any other way to get rid of those classes?
 
I haven't tried to do this but have you looked at the options here?

AdminCP >> Setup >> Options >> User options >> User banners (near the bottom)
 
I guess the right way to do this is with an custom addon. This I think replaces the whole fnUsernameClasses function, but at least I got rid of the span with the classes.

Code:
<?php
namespace Something\UserClasses;
class UserClasser extends \XF\Template\Templater
{
    public function fnUsernameClasses($templater, &$escape, $user, $includeGroupStyling = true)
    {
      $classes = [];
      return implode(' ', $classes);
    }
}

But rather than overriding the whole function, I'd just like to eliminate this part of the function (and return nothing):

Code:
foreach (['staff', 'moderator', 'admin'] AS $userType)
        {
            if (!empty($user["is_{$userType}"]))
            {
                $classes[] = "username--{$userType}";
            }
        }
 
I managed to pick up the abovementioned function and leave the parent like it is with the parent::fnUsernameClasses.

So the addon pretty much works now, it ain't pretty but it works and have no plans to release it anyways.
 
Back
Top Bottom