MyBB Community Forums

Full Version: Group conditional
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I'm wondering how I could let a specific group see something and the rest now, or vice versa.
I have ZingaBurga's PHP Conditional in Templates installed already.
Any help? Thanks!
I'm not sure of the exact syntax of the conditional statements but you can try something like this:

<if condition="$mybb->user['usergroup'] == 4">
stuff to show
</if>
or
<if($mybb->user['usergroup'] == 4)>
stuff to show
</if>
Should be something like this:
<if $mybb->user['usergroup'] == 4 then>
stuff to show
</if>
or
<if $GLOBALS['mybb']->user['usergroup'] == 4 then>
stuff to show
</if>
how about showing to multiple user group? example registered and guest only can see the template?

2, 1? need to add comma? cause its not working
<if $GLOBALS['mybb']->user['usergroup'] == 1 || $GLOBALS['mybb']->user['usergroup'] == 2 then>

??
thanks a lot mattR! it works like a charm! Big Grin
(2009-08-04, 08:29 AM)MattRogowski Wrote: [ -> ]<if $GLOBALS['mybb']->user['usergroup'] == 1 || $GLOBALS['mybb']->user['usergroup'] == 2 then>

How would I adjust the syntax to show something UNLESS it's a specific user group?

Example:
<if $GLOBALS['mybb']->user['usergroup'] != 13 then>
something to show
</if>

does that look right?
I'm doing something wrong because with the code as I've mentioned above, I'm getting this error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/myforum/public_html/forum/global.php(500) : eval()'d code on line 9
if(!$mybb->user['usergroup'] == 13){
something to show
}
(2011-02-22, 07:51 PM)Malcolm. Wrote: [ -> ]
if(!$mybb->user['usergroup'] == 13){
something to show
}

How would you reverse that to Show Unless usergroup 13...

I tried != but that didn't do it
Malcolm, my apologies, I see you added the negative at the beginning, before $mybb - I'll give that a shot - thank you
This would show content to everyone except that group.

if(!$mybb->user['usergroup'] == 13){
something to show
}

This would show content to only that group.

if($mybb->user['usergroup'] == 13){
something to show
}
Pages: 1 2 3