Resource icon

Custom Staff Online Titles for Xenforo 2

Brad Padgett

Well-known member
Brad Padgett submitted a new resource:

Custom Staff Online Titles for Xenforo 2 - replace ordinary usertitle for staff online with custom staff titles for one or multiple usergroups

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.

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...

Read more about this resource...
 
This only works for the single usergroup you use. If you try to use multiple usergroups, it does not work. I'm working on a fix right now and will update the resource when ones found. If someone knows the correct way to make multiple code entries for the same code (for more than one usergroup) feel free to chime in. I think there may be a better conditional that can be used for it to work correctly though I'm still searching.
 
This only works for the single usergroup you use. If you try to use multiple usergroups, it does not work. I'm working on a fix right now and will update the resource when ones found. If someone knows the correct way to make multiple code entries for the same code (for more than one usergroup) feel free to chime in. I think there may be a better conditional that can be used for it to work correctly though I'm still searching.
Rich (BB 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>
 
I’m not seeing the point in this. You can name the default user group titles in the ACP, doing this modification will break any custom user title set by an individual if they have the permissions to do so.

Also this bit in the description isn’t the way permissions should work in XenForo, Registered should be the primary for everyone. Staff user titles will override the registered group titles by default.
I'd also like to add one note to this. Make sure your primary usergroup is your staff usergroup or this won't work. Initially from Xenforo clean install all primary usergroups are registered and the staff groups are all secondary. This will keep you from getting it to work. You will need to make the staff usergroup your primary usergroup.
 
I’m not seeing the point in this. You can name the default user group titles in the ACP, doing this modification will break any custom user title set by an individual if they have the permissions to do so.

There is a point to it. I used the same type of code for XF1 numerous times as have many others. I actually learned this technique from someone else. First off, it does not break any user title. Don't believe me? Try yourself and then reply with a screenshot. All it does it change how the usertitle displays in staff online. Really, I'm not lying. That's all it does.

You can't even view the staffs usergroup name without it in staff online. Yeah you can change the usertitle to a staff name but not everyone wants to have their user title be their staff name. At least I don't, because I have user ranks

Also this bit in the description isn’t the way permissions should work in XenForo, Registered should be the primary for everyone. Staff user titles will override the registered group titles by default.

The staff online user title has nothing to do with the forum user title, absolutely nothing at least in the code I provided. Also who say's registered should be your primary usergroup? You can choose whatever usergroup you want as the primary. At least that's what I did and I've been fine for a long time.

Possibly that may be your standard but it does not have to be.

I'm surprised you got so many likes on something that is completely wrong. Feel free to correct me as I'd love to hear it. Your wrong.
 
The staff online user title has nothing to do with the forum user title, absolutely nothing at least in the code I provided. Also who say's registered should be your primary usergroup? You can choose whatever usergroup you want as the primary. At least that's what I did and I've been fine for a long time.

Possibly that may be your standard but it does not have to be.

I'm surprised you got so many likes on something that is completely wrong. Feel free to correct me as I'd love to hear it. Your wrong.
It's not that it's wrong to have another usergroup as the primary, but it not recommended, by Xenforo. The official recommendation is to have Registered as the primary group and then add secondary groups.

https://xenforo.com/xf2-docs/manual/groups-permissions/

Also, not doing so can set you up for issues with certain addons that do not anticipate this. I can't recall which addon it was that brought this to light but I recall reading about it not too long ago, one of @Xon's IIRC
 

I was trying to be rude or anything. Just trying to help.

@DL6 I tried your code and it worked. Will update resource.

I appreciate the help guys. I'm actually a really nice guy and wasn't trying to come off rude, I just had to make clear the purpose it's used for.

It's basically impossible to get the staff usergroup custom name to display in staff online without doing this unless you give it that specific user title which because like I said since I use user ranks, I didn't want to do.
 
I don't use the code provided and mine shoes custom or default staff user titles
View attachment 163010

That's the title though. Not the custom staff name. If you want your user title to display then the staff online will easily display it as it displays all user titles.

But if you want to have a different user title and not your staff user title. For instance if you want to use the user title ladder then this is what I do.
 
It's not that it's wrong to have another usergroup as the primary, but it not recommended, by Xenforo. The official recommendation is to have Registered as the primary group and then add secondary groups.

https://xenforo.com/xf2-docs/manual/groups-permissions/

Also, not doing so can set you up for issues with certain addons that do not anticipate this. I can't recall which addon it was that brought this to light but I recall reading about it not too long ago, one of @Xon's IIRC

Thanks for your reply. I actually know there's a code for the secondary usergroup to work as well but this is just something I picked up from a close friend and never actually tried to use the secondary usergroup conditional. I always used it as the primary.

I will add the secondary usergroup version if someone finds or knows it. I really appreciate it.
 
That would be awesome if that is possible too, that will work for everyone for sure!

I guess I'll wait to update the resource until someone knows or if I find a way. I'll start searching. The code @DL6 provided was very helpful but we should do it the right way. I'll update you guys when we find it.

Thanks
 

Indeed it does. I just tried it.

This never worked for me in Xenforo 1 when I had the staff usergroup as secondary. Not sure why or if it would if I tried again. What matters if we have the correct code now. I really appreciate you taking the time to reply. I actually remember a Xenforo 1 resource in which I had seen for the Xenforo 1 version. I never took the time to find it though.

Anyways thanks for the help. I'll update the resource now.
 
Also, not doing so can set you up for issues with certain addons that do not anticipate this. I can't recall which addon it was that brought this to light but I recall reading about it not too long ago, one of @Xon's IIRC
Most of my add-ons assume the registered user group is always on the account, and only setup defaults that way. You can work around it, but it involves wading through as sea of permissions and a couple odd places depending on the add-on.
 
Most of my add-ons assume the registered user group is always on the account, and only setup defaults that way. You can work around it, but it involves wading through as sea of permissions and a couple odd places depending on the add-on.

Appreciate the info. Only reason I had said the staff titles didn't work unless staff was your primary usergroup and not registered is it never worked for me on Xenforo 1. After testing this works the normal way. Which this is actually something new I just learned myself about registered always needing to be the primary. I never knew that standard was important but I know now.

Anyways all this info in the thread I'm sure is helping a lot of people so thanks.
 
Back
Top Bottom