PDA

View Full Version : Check if user is logged in, and part of a usergroup.


Revpolar
08-05-2005, 02:59 PM
And allo there. I'm trying to get a non-vb page to check if a user is logged in, and then if it's part of that membergroup. So far, the login check is working all fine and dandy, however the membergroup check isn't, and I'm assuming that it's because if the user is in multiple groups, it isn't a simple number that's checked, there's also commas in the table. So far this is what I have:
<?php
require("./global.php");

if ($bbuserinfo['userid']!=0) {

echo '1) Yes.';
if ($bbuserinfo[membergroupid'] == '6') {

echo '<br />2) Yes.';

}
else { echo '<br />2) No.';
}
}
else {
echo '1) No.';
}

?>
Now, it checks if the user is logged in, that bit works, but the usergroupid doesn't work. Is there any way that I can take what's stored in the membergroupid field (in the users table) and make it so that it checks every number seperatly?

Andreas
08-05-2005, 03:00 PM
As you are using $bbuserinfo, I guess you've required the vBulletin Backend.

Then you can use

if (is_member_of($bbuserinfo, X))
{
// Do stuff
}

Revpolar
08-05-2005, 03:54 PM
Ahhh, dandy, that did the trick! Thanks m8! :)