Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Secondary usergroup conditional
Gstone Offline
Member
***
Posts: 55
Joined: May 2012
Post: #1
Secondary usergroup conditional
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!

01-18-2013 04:48 PM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,333
Joined: Mar 2010
Post: #2
RE: Secondary usergroup conditional
Something like in this thread?
http://mybbhacks.zingaburga.com/showthre...851&page=4

01-19-2013 02:40 AM
Find all posts by this user Quote this message in a reply
Gstone Offline
Member
***
Posts: 55
Joined: May 2012
Post: #3
RE: Secondary usergroup conditional
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>

01-19-2013 05:01 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,333
Joined: Mar 2010
Post: #4
RE: Secondary usergroup conditional
For the viewer, try to use $mybb->user['additionalgroups']

01-19-2013 05:16 AM
Find all posts by this user Quote this message in a reply
Gstone Offline
Member
***
Posts: 55
Joined: May 2012
Post: #5
RE: Secondary usergroup conditional
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>

(This post was last modified: 01-19-2013 06:48 AM by Gstone.)
01-19-2013 06:48 AM
Find all posts by this user Quote this message in a reply
RateU Offline
Administrator
*******
Posts: 2,333
Joined: Mar 2010
Post: #6
RE: Secondary usergroup conditional
I think the code will only work if they have one additional usergroups only?

01-20-2013 06:44 AM
Find all posts by this user Quote this message in a reply
Gstone Offline
Member
***
Posts: 55
Joined: May 2012
Post: #7
RE: Secondary usergroup conditional
Just now tried it and it worked with 2 additional groups (with the default Registered still being primary).
01-20-2013 12:54 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,338
Joined: Jan 2008
Post: #8
RE: Secondary usergroup conditional
(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.

My Blog
01-20-2013 01:40 PM
Find all posts by this user Quote this message in a reply
nier3 Offline
Member
***
Posts: 124
Joined: Jul 2012
Post: #9
RE: Secondary usergroup conditional
Hi, I'm trying to show in postbit this:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
<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

08-03-2015 07:15 AM
Find all posts by this user Quote this message in a reply
leefish Offline
Hamster
*******
Posts: 1,009
Joined: Apr 2010
Post: #10
RE: Secondary usergroup conditional
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.



[Image: leelink.gif]
MYBB1.6 & XThreads
08-03-2015 08:35 AM
Visit this user's website Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: