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

question - how to hide a custom usergroup's posts from unregistered visitors

#1
Just bought Xenforo and imported my vbulletin forum into it. Xenforo is great. I just need to make one customization though that my vbulletin had.

I have a custom usergroup called "Registered PRIVATE Users", whose posts should NOT be displayed to unregistered visitors.

In vbulletin, my custom IF-conditional code looks like this, which is in the postbit template:
<if condition="$bbuserinfo[userid] || ($post[displaygrouptitle] != "Registered PRIVATE Users" && !$bbuserinfo[userid])">

CODE TO SHOW POST

</else>

DISPLAY NOTHING

</if>
Basically, to view a post you have to be either...
a) a registered member
Or
b) a visitor, but it can't be a post by someone in the group Registered Private User


My question is, how would I code this into Xenforo? It should be pretty simple I imagine.
 

Jake Bunce

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

Add the red code. You need to change the blue pieces appropriately (group_id and guest message). This is a direct translation of your condition:

Code:
		<xen:hook name="message_content" params="{xen:array 'message={$message}'}">
		<div class="messageContent">		
			<article>
				<blockquote class="messageText ugc baseHtml{xen:if $message.isIgnored, ' ignored'}">
					<xen:include template="ad_message_body" />
					<xen:if is="{$visitor.user_id} OR (!{xen:helper ismemberof, $message, 4} AND !{$visitor.user_id})">
					{xen:raw $message.messageHtml}
					<xen:else />
					DISPLAY NOTHING
					</xen:if>
				</blockquote>
			</article>
			
			{xen:raw $messageContentAfterTemplate}
		</div>
		</xen:hook>