PDA

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


chsmith700
12-05-2009, 08:56 PM
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
12-05-2009, 09:29 PM
if (is_member_of($vbulletin->userinfo, 6)) {
somestuff
} else {
someotherstuff
}

chsmith700
12-06-2009, 07:13 PM
Awesome, thanks alot!

Weetabix
12-26-2009, 11:48 AM
Could this be used to enable style selection for certain (sub) usergroups only?

TransAmDan
08-20-2015, 05:18 PM
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
08-20-2015, 05:24 PM
Try adding the following to the top of your Content (PHP code)

global $vbulletin;