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

Conditional help

Ranger375

Well-known member
#1
I'm basically trying to edit the member_user_info template for all my user groups but I am having problems. How would I make the below appear for just admins with an if conditional?

<span class="userrank">Admin</span>



I've searched the forum but havent found an answer :\
 

Jake Bunce

XenForo moderator
Staff member
#2
Admin CP -> Appearance -> Templates -> message_user_info

Add this code:

Code:
		<xen:if is="{$user.is_admin}">
			<span class="userTitle">ADMIN RANK</span>
		</xen:if>
...as shown below:

Code:
<xen:if is="!{$isQuickReply}">
	<h3 class="userText">
		<a {xen:if $user.user_id, 'href="{xen:link members, $user}" '}class="username" itemprop="name">{xen:helper richUserName, $user}</a>
		<xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user}</xen:contentcheck></em></xen:if>

		<xen:if is="{$user.is_admin}">
			<span class="userTitle">ADMIN RANK</span>
		</xen:if>

	</h3>

	<xen:if hascontent="true">
		<div class="extraUserInfo">
This is what you get (the rank below the title):

Screen shot 2010-11-07 at 4.10.08 PM.png
 

Ranger375

Well-known member
#3
Admin CP -> Appearance -> Templates -> message_user_info

Add this code:

Code:
		<xen:if is="{$user.is_admin}">
			<span class="userTitle">ADMIN RANK</span>
		</xen:if>
...as shown below:

Code:
<xen:if is="!{$isQuickReply}">
	<h3 class="userText">
		<a {xen:if $user.user_id, 'href="{xen:link members, $user}" '}class="username" itemprop="name">{xen:helper richUserName, $user}</a>
		<xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user}</xen:contentcheck></em></xen:if>

		<xen:if is="{$user.is_admin}">
			<span class="userTitle">ADMIN RANK</span>
		</xen:if>

	</h3>

	<xen:if hascontent="true">
		<div class="extraUserInfo">
This is what you get (the rank below the title):

View attachment 5641

Thanks, Jake. I've been trying to figure out how to get the conditionals to work with the css ranks here: http://xenforo.com/community/threads/user-ranks-in-css-no-images-required.7731/#post-108349

Basically, the rank appears like your example above, but without the same appearance. When I use the example in the post above, the rank appears on everyones post regardless of user group.
 

Ranger375

Well-known member
#4
Ahhh nm, he updated the post with

<xen:if is="{$user.is_admin}">
<span class="userrank">Administrator</span>
</xen:if>


Thanks again Jake
 

Ranger375

Well-known member
#6
Regarding that thread:

http://xenforo.com/community/threads/user-ranks-in-css-no-images-required.7731/

I was just posting a change to his instructions. But it appears that the author just updated his post with that very change. Refer to that thread again.
Thanks, that worked perfectly. How would I figure out what to write in the conditional for my custom usergroups? <xen:if is="{$user.is_?????}"> I tried putting in the group and the group number but it didn't work.
 

Jake Bunce

XenForo moderator
Staff member
#7
This will check an individual primary usergroup:

Code:
<xen:if is="{$user.user_group_id} == 2">

</xen:if>
Change the 2 to the user_group_id you want to check.