Custom Staff Online Titles In Xenforo 2. Show your staff usergroup name in staff online while still being able to use a custom user title

TopSilver

web designer
Administrator
Joined
Mar 10, 2017
Messages
249
Likes
41
#1
This is a short and simple guide to achieve custom staff online titles since ordinarily it shows your profile user title instead of a staff title for staff online in Xenforo 2. I originally posted this on xenforo.com but I am the author of that resource so I wanted to post it here.

Go to the template widget_members_online.

Find:

Code:
        <xf:if is="$user.is_staff">
                            <li class="block-row">
                                <div class="contentRow">
                                    <div class="contentRow-figure">
                                        <xf:avatar user="$user" size="xs" />
                                    </div>
                                    <div class="contentRow-main contentRow-main--close">
                                        <xf:username user="$user" rich="true" />
                                        <div class="contentRow-minor">
                                            <xf:usertitle user="$user" />
                                        </div>
                                    </div>
                                </div>
                            </li>
                        </xf:if>
For Administrator, Super Moderator, and Moderator replace with:

Code:
<xf:if is="$user.is_staff">
<li class="block-row">
<div class="contentRow">
<div class="contentRow-figure">
<xf:avatar user="$user" size="xs" />
</div>
<div class="contentRow-main contentRow-main--close">
<xf:username user="$user" rich="true" />
<div class="contentRow-minor">
<xf:if is="{{ $user.isMemberOf(x) }}">
<div class="usertitle">Administrator</div>
<xf:elseif is="{{ $user.isMemberOf(y) }}" />
<div class="usertitle">Super moderator</div>
<xf:elseif is="{{ $user.isMemberOf(z) }}" />
<div class="usertitle">Moderator</div>
<xf:else />
<xf:usertitle user="$user" />
</xf:if>
</div>
</div>
</div>
</li>
</xf:if>
You will need to replace x, y, or z inside of this with your usergroup id:

To find the number of your usergroup click on the usergroup in settings from your admin panel and look in the URL. The number you see in the URL is the number of your usergroup.

Then you would simply change the user title between the correct div to the appropriate title for it to appear in staff online.

To do this for more than 3 usergroups you simply add another xenforo elseif statement like above and place it right after the first 3.

Now when you go to view staff online the usertitle it should have now be the custom usertitle.

What this tutorial allows you to do:

It allows you to have a staff title in staff online of your choosing without having to use the default user title given to staff. It allows you to use a custom title only visible in staff online. This is mainly used when someone doesn't want their user title to be their staff name and instead wants to use user ranks or another form of showing their staff identity. In other words your only changing the title of the staff online title.

Let me know if you need any help with this. It's fairly simple to do with the code I provided.

- TopSilver