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

Template files see if user is banned

Discussion in 'XenForo Questions and Support' started by blackvoid, Jul 17, 2011.

  1. blackvoid

    blackvoid Active Member

    I would like to see if the user is banned in the view message template. If the user is banned it will show a static image url and if not it will show the users avatar.

    I couldnt find a user variable to check this.

    Best regards
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Quick and dirty template edit:

    Admin CP -> Appearance -> Templates -> message_user_info

    Replace this code:

    Code:
    	<xen:hook name="message_user_info_avatar" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
    		<div class="avatarHolder">
    			<xen:avatar user="$user" size="m" />
    			<!-- slot: message_user_info_avatar -->
    		</div>
    	</xen:hook>
    
    With this:

    Code:
    	<xen:hook name="message_user_info_avatar" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
    		<div class="avatarHolder">
    			<xen:if is="{$user.is_banned}">
    				<a href="{xen:link members, $user}" class="avatar Av{$user.user_id}m" data-avatarHtml="true"><span class="img m" style="background-image: url('PATH/TO/BANNEDIMAGE.GIF')"></span></a>
    			<xen:else />
    				<xen:avatar user="$user" size="m" />
    				<!-- slot: message_user_info_avatar -->
    			</xen:if>
    		</div>
    	</xen:hook>
    
    You need to change PATH/TO/BANNEDIMAGE.GIF appropriately. And ideally the image should be 96x96 to match the size of other avatars.

    This is hard-coding the avatar HTML so it isn't future-proof should the avatar code change in a future version.
     
    Eagle and Abracadaniel like this.
  3. blackvoid

    blackvoid Active Member

    Yeah, I know Ive changed a few things in the template files already :)

    Thank you for the help.
     

Share This Page