MyBB Hacks

Full Version: <if statements ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, i'm new here and i'm finding this place very interesting. I had a small problem with groupid usage in the template files to show or hide something from certain groups. For example i would like to hide the "The newest member: xxx" line from the board stats. How can we achieve this by using the <if gid=""> in the template files? Can anyone please give the available <if clauses for various groups? thanks
I know this one

Code:
<if $GLOBALS['mybb']->user['usergroup'] == 4 || $GLOBALS['mybb']->user['usergroup'] == 5 || $GLOBALS['mybb']->user['usergroup'] == 6 then> stuff for usergroup 4,5,6</if>


That would show things ONLY to the gids above.

Thank you very much leefish \o/

I love you man, lol.
what about <if not statement?

i want to make some stuff visible to all groups except guests. so it will better to add only guest group by using "if not" clause, which is better than adding all group ids in the "if" statement.

Code:
<if $GLOBALS['mybb']->user['usergroup'] != 1 then>
Whatever we put here, will be viewable by all usergroup, except usergroup id 1 (by default, Guests).
</if>

worked fine with single group but can we add more than 1 group with not clause?

for exapmle: to hide it from banned members also?
<if $GLOBALS['mybb']->user['usergroup'] != 5 || $GLOBALS['mybb']->user['usergroup'] != 7 then> Text </if>

will work?
thanks to RateU and leefish
i figured it out Smile
It's better to use it like this (I think):

Code:
<if !in_array($GLOBALS['mybb']->user['usergroup'], array(1,5,7)) then>
Text
</if>

worked like charm, rateu

i thought in different way <if $GLOBALS['mybb']->user['usergroup'] != 5 && $GLOBALS['mybb']->user['usergroup'] != 7 then> Text </if>

using && did the work. but your code is very simple to add any number of gids easily in array. i will make use of your code. initially leefish helped with her code
<if $GLOBALS['mybb']->user['usergroup'] == 4 || $GLOBALS['mybb']->user['usergroup'] == 5 || $GLOBALS['mybb']->user['usergroup'] == 6 then> stuff for usergroup 4,5,6</if>
which will be long if we want to use more codes. but using your array code, the length is decreased alot and simple. Smile
Reference URL's