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

XF 1.4 IF condition to shows x banner to usergroups?

Discussion in 'XenForo Questions and Support' started by Okenyon, Aug 3, 2015.

  1. Okenyon

    Okenyon Active Member

    Hey all, I don't code so kindly write the code for me if you'd be so kind,

    Is there a way to serve banner X to normal users, but banner Y if you're in a certain user group?

    By banner I mean an adbanner just using templates and HTML.
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

    The conditional statement guide in my signature explains how to do that.
     
  3. Okenyon

    Okenyon Active Member

    Thank you, i've just had a read through but my head goes missing on stuff like this, if anyone would be so kind to show me the exact code to show a banner to different usergroups, thank you.
     
  4. James

    James Well-Known Member

    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, x, y, z}">
    insert the code for your banner here
    </xen:if>
    
    x, y, z = replace with a comma-separated list of the usergroups you want to show the banner to (e.g. 5, 12, 19).
     
  5. Okenyon

    Okenyon Active Member

    Thank you @James however what if I wish to show one banner to all uaergroups and another to one specific user group?
     
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    Invert the condition and only use the group you wish to not see it: !{xen:helper ...}

    And then use another one that targets that group.
     
  7. James

    James Well-Known Member

    Combine an if-else:
    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, x, y, z}">
    insert the code for the specific usergroup(s) here
    <xen:else />
    insert the code for everyone else here
    </xen:if>
    
     

Share This Page