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

Template Conditional - User Group

#1
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?
 
#3
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?
 

Brogan

XenForo moderator
Staff member
#4
You can't use the conditional statements in EXTRA.css, only in the templates and only where the $post param is available.
 

RichardKYA

Well-known member
#7
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 :)
 

Brogan

XenForo moderator
Staff member
#8
You put the user group ID only, which you can find from the URL when editing the user group.
 

RichardKYA

Well-known member
#9
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?