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

How do I properly make the sidebar display only for specific usergroups?

EQnoble

Well-known member
#1
I have successfully added a sidebar Item to the thread_view for display when viewing threads and now was wondering what is the correct way to set the condition to display only if visitor is x,y,or z usergroupID

this is what I basically added

Code:
 <xen:sidebar>

    <xen:include template="sidebar_xx_item" />

 </xen:sidebar>
What kind of conditions and how can it be done is basically what I'm asking of anyone that can offer the help.
 

EQnoble

Well-known member
#3
This works just fine...THANK YOU!

Is there something similar for a specific userID as well...my brain is saying something like $user, 2 but I can't think of how to put that together.
 

Shadab

Well-known member
#4
The user ID is stored in the $visitor array, with the key: user_id.
So you can try...
Code:
<xen:if is="{$visitor.user_id} == N">
    <!-- Stuff -->
</xen:if>
 

EQnoble

Well-known member
#5
Works just fine there sir! Note to anyone trying it...if you don't supply it with an actual userID and leave such as the example N upon saving xenforo will throw you back an error..don't fret just supply your user id ( I used 1 for admin ) and save and all should be fine.

Thanks again Shedab
 

Shadab

Well-known member
#6
You're welcome.

And yes, "N" is to be replaced with either an integer or a variable containing an integer;
to work correctly.
 

Tilkißey

Well-known member
#10
Hey while I got yah with all the answers here :), is there a similar snippit I could use for forumID ?
u can use for forumIDs this code, an example in thread_view template ( i use in that )
HTML:
<xen:if is="in_array({$forum.node_id}, array(5,7,8,9,26))">
u can edit this code for ur main target
like-->
HTML:
<xen:if is="in_array({$visitor.user_id}, array(1,2,3,54,645645))">
via using this codes, u will add less codes, not code crowding (sorry my English =) )