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

jeffwidman

Active member
#1
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.
 

Brogan

XenForo moderator
Staff member
#2
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}
 

jeffwidman

Active member
#3
Thanks!
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.
 
Top