1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Styling and Customization Questions' started by jeffwidman, Jan 17, 2015.

  1. jeffwidman

    jeffwidman 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.
  2. Brogan

    Brogan 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}
    jeffwidman likes this.
  3. jeffwidman

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

Share This Page