XF 1.4 How to publicly expose user group's the visitor belongs to?


Active member
How do I print the user_group_ids that the current page visitor belongs to?

This is not the same as a conditional where I check if a user belongs to certain user groups.

I need to expose them in the html source so that my ad server can target different ads to different user groups.


XenForo moderator
Staff member
They are stored in $visitor.user_group_id and $visitor.secondary_group_ids.

You can dump them in the templates using:
{xen:helper dump, $visitor.user_group_id}
{xen:helper dump, $visitor.secondary_group_ids}


Active member
Exactly what I needed.

For anyone coming along later, when I tested this, "helper dump" function also spits out info I didn't need, like datatypes.
So I just used "{$visitor.user_group_id},{$visitor.secondary_group_ids}" and that spits out a comma separated list of integers.