XF 2.3 Make members the default tab for Online list

Mr Lucky

Well-known member
Licensed customer
I would like to make Members the deafult tab for the online list (Current Visitors) instead of Everyone.

Can anyone please help? Thank you.
 
You can do this with a template modification. Go to Admin Panel > Appearance > Template modifications and create a new one:

Template: online_list
Search type: Simple replacement
Find: data-active-tab="everyone"
Replace: data-active-tab="members"

That switches the default active tab from "Everyone" to "Members" when the Current Visitors page loads. Quick and clean — no JS needed.
 
My earlier suggestion was wrong — data-active-tab doesn't exist in that template. Sorry about that!
The active tab is actually controlled server-side by the $typeLimit variable based on the URL parameter ?type=. When you visit /online/ with no parameter, it defaults to "Everyone".
Here's the correct approach using a JavaScript redirect:
Admin CP → Appearance → Template modifications → Add
  • Title: Default online list to Members tab
  • Template: online_list
  • Search type: Simple replacement
Find:
Code:
<xf:title page="{$page}">{{ phrase('current_visitors') }}</xf:title>
Replace:
Code:
<xf:title page="{$page}">{{ phrase('current_visitors') }}</xf:title>
<xf:if is="!$typeLimit"><script>window.location.replace('{{ link('online', null, {'type': 'member'}) }}');</script></xf:if>
This checks if no type filter is set and instantly redirects to the Members tab. The redirect is so fast it's barely noticeable.
 
This works but no longer allows view of everyone tab. I presume that's because it redirects.
It appears that the above solution is AI generated and not the best option. To restore the function so you can use the everyone tab, please see this solution. This one keeps everything working normally, but does get the result you'd like to show the members tab by default.
 
It appears that the above solution is AI generated and not the best option.
Hmm, how does AI get to be a licensed customer?

It appears that the above solution is AI generated and not the best option. To restore the function so you can use the everyone tab, please see this solution. This one keeps everything working normally, but does get the result you'd like to show the members tab by default.
Thanks but for some reason this is not working. I can see it should be as marked as solution in the linked thread.
 
Hey Mr Lucky, sorry again for my earlier suggestions — both were wrong and I should've checked the template before posting.
I went back and looked at the actual online_list template. The tabs are just plain links — the active one is set server-side by the $typeLimit variable from the ?type= URL parameter. There's no data-active-tab attribute anywhere.
The solution ENF linked (from fords8) is the right approach. It targets the widget_members_online template. The idea is to change the widget header link so clicking "Current visitors" in the sidebar goes straight to Members. All other tabs still work.
Create a template modification (Admin → Appearance → Template modifications → Add):
  • Title: Default online widget to Members
  • Template: widget_members_online
  • Search type: Simple replacement
  • Find: <a href="{{ link('online') }}">{$title}</a>
  • Replace: <a href="{{ link('online', null, {'type': 'member'}) }}">{$title}</a>
If it's still not working, try rebuilding caches (Admin → Tools → Rebuild caches) and make sure the template name is exactly widget_members_online.
One caveat: this only changes where the sidebar widget link goes. If someone visits /online/ directly from a bookmark, they'll still see Everyone first. Changing the actual page default would need a controller-level modification.
 
Back
Top Bottom