MyBB Community Forums

Full Version: [Question] <if $mybb->user['additionalgroups']
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
deleted
<if in_array($mybb->user['additionalgroups'], array('91', '23', '62')) then>

can you elaborate second requirement.
though you can restrict content based on user IDs, I'd suggest to try group based permissions.

<if $mybb->user['uid'] != X then>
content not visible to user X
</if>

<if $mybb->usergroup['gid'] != Y then>
content not visible for users of group Y
</if>

(template conditionals plugin)
deleted
(2013-07-26, 06:08 PM).m. Wrote: [ -> ]
<if in_array($mybb->user['additionalgroups'], array('91', '23', '62')) then>

(template conditionals plugin)

Hi, this code doesn't work Sad Is there a new code for Mybb 1.8?

Thank you
^ have you installed template conditionals plugin ? can you post exact code you have used ..
Hi, I have used this code in postbit template:

<if in_array($mybb->user['additionalgroups'], array(45,42,23)) then>
 
 <li style="background-color:blue;">
 
 <i class="fa fa-star"></i>
 
 {$post['usertitle']} 
 
 </li>

</if>

If user is in additionalgroups 45,42,23 then usertitle with style is shown.

Maybe the code doesn't work in postbit template but only in showthread template? Sad

I have PHP and Template Conditionals (2.0), I use <if> without problems but with this code doesn't work.


For example this code works perfectly also in postbit template:

<if $mybb->user['usergroup'] == 4 then>{$post['usertitle']}</if>
$mybb->user['additionalgroups'] is not an array. You need to separate it by comma before checking it with array_intersect() rather than in_array().
<if array_intersect(array(45,42,23), explode(",", $mybb->user['additionalgroups'])) then>

Also, please don't hijack multiple other old threads, just open a new one..
(2015-08-03, 09:40 PM)Destroy666 Wrote: [ -> ]$mybb->user['additionalgroups'] is not an array. You need to separate it by comma before checking it with array_intersect() rather than in_array().
<if array_intersect(array(45,42,23), explode(",", $mybb->user['additionalgroups'])) then>

Also, please don't hijack multiple other old threads, just open a new one..

Hi, it doesn't work Sad the stuff into <if etc additionalgroups> is always shown to all users, not only to 45,42,23 additional groups Sad

And sorry, in future I'll add new thread :x
You must be testing/describing it wrong if both the code above and this (which is another simple method): http://mybbhacks.zingaburga.com/showthre...6#pid18696 are not working for you.

I just tested with different numbers and it works for me.