Log in

View Full Version : Checking if someone is a moderator


MrApples
01-03-2008, 10:04 PM
How would I check if a someone is a moderator of a specific forum with PHP?

I've tried this but it's not parsing correctly on the foreach argument...
function forum_is_moderated($fid){
global $vbulletin, $imodcache;
foreach ($imodcache["$fid"] AS $moderator)
{
if ( $vbulletin->userinfo['userid']; == $moderator['userid'] ) {
return 1;
}
// For first mod else {
// For first mod return 0;
// For first mod }

}
}

Opserty
01-03-2008, 10:11 PM
can_moderate() Returns whether or not the given user can perform a specific moderation action in the specified forum

boolean can_moderate ([integer $forumid = 0], [string $do = ''], [integer $userid = -1], [string $usergroupids = ''])

integer $forumid: Forum ID
string $do: If you want to check a particular moderation permission, name it here
integer $userid: User ID
string $usergroupids: Comma separated list of usergroups to which the user belongshttp://members.vbulletin.com/api/vBulletin/_includes_functions_php.html#functioncan_moderate

So you could do something like.

if(can_moderate(4, '', 1))
{
//...
}

MrApples
01-03-2008, 10:51 PM
Thanks, that should work much better.

Does that require including a specific file by any chance?

Opserty
01-04-2008, 08:54 AM
You'll need to include the vBulletin backend. (Global.php) or You could try mimicking the function by looking at the PHP source for the function in includes/functions.php and writing something similar in your own code.