MyBB Hacks

Full Version: Secondary usergroup conditional
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
hey there,

i was curious as to if there was some sort of variable i could use for secondary usergroups. My assumption is that this is not possible, but i would rather ask just in case.

i'm currently trying to use a similar if statement:

Code:
<if !in_array($GLOBALS['mybb']->user['usergroup'], array(8,9,10) then>
blablabla
</if>


the above will hide the content to the usergroups i do not wish for them to see. now the thing is, the above usergroups are all used as secondary usergroups. a member will still be in usergroup 2, so the "hidden" content will still be shown to them even if they are added to one of the groups above.

is there any way around this? i simply want content to be removed after a user has been granted their secondary usergroup.

Thank you for any help!

thank you!

Will this work on forumdisplay? i've been attempting to do this, but the following code hides content to all users. I changed 15 to the appropriate group.

PHP Code:
<if (stripos(','.$memprofile['additionalgroups'].',', ',15,') !== false) then>
Show Stuff on profile where profile owner is in ADDITIONAL usergroup 15
</if>

For the viewer, try to use $mybb->user['additionalgroups']
Ah thank you much. i used to the following and it works perfectly:

PHP Code:
<if !in_array($mybb->user['additionalgroups'], array(8,13)) then>
hide this content to the above secondary usergroups
</if>

I think the code will only work if they have one additional usergroups only?
Just now tried it and it worked with 2 additional groups (with the default Registered still being primary).
(01-20-2013 12:54 PM)Gstone Wrote: [ -> ]Just now tried it and it worked with 2 additional groups (with the default Registered still being primary).
It may work, or it may not.  I personally wouldn't trust it.

If you want to know details, PHP string to int comparisons work by typecasting the string to an int, meaning that if the first listed additional group is in the array you supply, it will match, but if it isn't, it never will match.
Hi, I'm trying to show in postbit this:

PHP Code:
<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>


But with additional groups doesn't work, it's like if "additionalgroups" thing there isn't, it shows always style also on other users of other usergroups Frown

maybe this?

Code:
<if (stripos(','.$mybb->user['additionalgroups'].',', ',45,') !== false) then>
Show Stuff where user is in ADDITIONAL usergroup 45
</if>


But no idea how to make that work with an array... or even if that above code will work.

Pages: 1 2
Reference URL's