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

XF 1.3 Conditional for multiple usergroups in message template

Discussion in 'Styling and Customization Questions' started by Michael, Jun 17, 2014.

  1. Michael

    Michael Active Member

    Hi guys I am wanting to include multiple usergroups with this conditional instead of the single usergroup, how do I go about it?

    <xen:if is="{xen:helper ismemberof, $message, 40}">
    Thank you.
  2. Brogan

    Brogan XenForo Moderator Staff Member

    Michael likes this.
  3. Michael

    Michael Active Member

    Thanks Brogan, I didnt realise that was in there :D
  4. Rudy

    Rudy Well-Known Member

    This is somewhat similar, although what I want to do is allow usergroup ID 20 to view something, yet if they are also in usergroup IP 36, to not view the content. We have a forum section which is automatically promoted after a given number of posts (promoting them to usergroup 20), yet we can revoke that by selection of secondary usergroup 36. The reason I do this is mainly so we can temporarily disable access without interfering with the automatic promotion of a member to usergroup 20. In short, 20 is automatic, and 36 revokes 20.

    I'm not sure if using an AND would be more appropriate, or some sort of IF/ELSEIF/ELSE loop.

    I tried this:

    <xen:if is="{xen:helper ismemberof, $visitor, 20} AND !{xen:helper ismemberof, $visitor, 36}">
    <p>show this</p>
    but the text still appears, and I get this error:

    Argument 1 passed to XenForo_Template_Helper_Core::helperIsMemberOf() must be an array, null given in /usr/www/.../xf/library/XenForo/Template/Helper/Core.php, line 1344
    Argument 1 passed to XenForo_Model_User::isMemberOfUserGroup() must be an array, null given, called in /usr/www/.../xf/library/XenForo/Template/Helper/Core.php on line 1352 and defined in /usr/www/.../xf/library/XenForo/Model/User.php, line 1683
    Seeing the note about using $visitor vs. $user, I changed the above instances to $user.

    <xen:if is="{xen:helper ismemberof, $user, 20} AND !{xen:helper ismemberof, $user, 36}">
    <p>show this</p>
    Now, the text does not appear in either case, and I still get the error message.

    Is it possible these template conditionals are not supported where I am trying to use them? I am trying to control viewing of a link in the membercard, along with a link in the user's drop-down menu, using conditionals but have had no luck as of yet. If they're not possible in these instances, then I can stop beating my head against the wall over this.

Share This Page