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

Template Conditional - User Group

Discussion in 'Styling and Customization Questions' started by TruthElixirX, Dec 15, 2013.

  1. TruthElixirX

    TruthElixirX Member

    I would like the background of a user's post to change according to their usergroup. What I mean is

    If user is group A, their background looks blue to everyone.
    If user is group B, their background looks red to everyone.


    Code:
    <xen:if is="{xen:helper ismemberof, $visitor, x}">
    This content will show to members of user group x
    </xen:if>
    This doesn't work, it just makes the background appear changed to every post when a user from that group views it. On vBulletin I did:

    Code:
    <if condition="is_member_of($post, 5,7)">
    Is there something similar for XenForo?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    <xen:if is="{xen:helper ismemberof, $post, x}">
     
  3. TruthElixirX

    TruthElixirX Member

    This doesn't seem to be working. In my extra.css I have tried:

    Code:
    <xen:if is="{xen:helper ismemberof, $post, 25}">
    .messageUserBlock div.avatarHolder {
      background: url("finalcopy.jpg") no-repeat scroll center center #101010;
      border-radius: 4px;
      padding: 10px;
    }
    </xen:if>
    
    <xen:if is="{xen:helper ismemberof, $post, 25, 38}">
    .messageUserBlock div.avatarHolder {
      background: url("finalcopy.jpg") no-repeat scroll center center #101010;
      border-radius: 4px;
      padding: 10px;
    }
    </xen:if>
    
    <xen:if is="{xen:helper ismemberof, $post, 38}">
    .messageUserBlock div.avatarHolder {
      background: url("finalcopy.jpg") no-repeat scroll center center #101010;
      border-radius: 4px;
      padding: 10px;
    }
    </xen:if>
    
    Nothing shows. It works without the conditional though. will it not work in the Extra.CSS template for some reason?
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    You can't use the conditional statements in EXTRA.css, only in the templates and only where the $post param is available.
     
  5. Valter

    Valter Active Member

    It would be great to have conditionals working in EXTRA.css.
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    Almost certainly not necessary.

    What are you trying to do?
     
  7. RichardKYA

    RichardKYA Well-Known Member

    Hello,

    Hope you don't mind me posting this here, but it's somewhat to do with this.

    How do I define my user group in this conditional

    <xen:if is="{xen:helper ismemberof, $visitor, x}">
    This content will show to members of user group x
    </xen:if>


    Where it has x, do I put the title of the user group with spaces included so if my user group is "12 - Gold Member", do I put it as that or do I put "12_-_Gold_Member" or something else completely?

    Thank you :)
     
  8. Brogan

    Brogan XenForo Moderator Staff Member

    You put the user group ID only, which you can find from the URL when editing the user group.
     
  9. RichardKYA

    RichardKYA Well-Known Member

    Ah, I see. Thank you.

    Whilst on the subject of user groups and blocking/showing certain areas, is there a way to block/hide user groups with a customField preference?

    On my site I am going to have different user groups for different ages, 15-17, 18-21, 21-25, etc. So I would I like to give users the option to block people from certain age groups. The reason being, while using other websites, I have noticed that adults tend to get annoyed with the younger generation, so it would be nice if they could block them completely if they wanted to. Or vice versa.

    Is something like that possible?
     

Share This Page