PDA

View Full Version : Check if User is in Usergroup (PHP)


chsmith700
05 Dec 2009, 22:56
Hello,

I am writing a custom script and having some issues verifying if a user is in a usergroup, not in the template file but in the PHP. I tried this but it doesnt seem to be working correctly, What am I doing wrong?

if ($userinfo['usergroupid'] == 6) {
somestuff
} else {
someotherstuff
}

I tried just doing an echo '<vb:if condition=\"is_member_of($vbulletin->userinfo, 6)\">' statement but when I do that is displays in the source an array.

ForumsMods
05 Dec 2009, 23:29
if (is_member_of($vbulletin->userinfo, 6)) {
somestuff
} else {
someotherstuff
}

chsmith700
06 Dec 2009, 21:13
Awesome, thanks alot!

Weetabix
26 Dec 2009, 13:48
Could this be used to enable style selection for certain (sub) usergroups only?

TransAmDan
20 Aug 2015, 20:18
I wonder if this should work in the forum Blocks area?
I have the following:-

if (is_member_of($vbulletin->userinfo, 6)) {
$my_output = '';
} else {
$my_output = ' google adsence code......';
}
return $my_output;


However no matter what usergroup I choose the advertising is always displayed. 6 is Admin usergroup and I am admin. I choose usergroup 1 for not logged in, and try that without being logged in, but it still displays the advertising.
I know its not a cached issue, as I just popped in some test text, and that was displayed.

MarkFL
20 Aug 2015, 20:24
Try adding the following to the top of your Content (PHP code)

global $vbulletin;