vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Checking if someone is a moderator (https://vborg.vbsupport.ru/showthread.php?t=166876)

MrApples 01-03-2008 10:04 PM

Checking if someone is a moderator
 
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...
PHP Code:

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

Quote:

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 belongs
http://members.vbulletin.com/api/vBulletin/_includes_functions_php.html#functioncan_moderate
So you could do something like.
PHP Code:

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.


All times are GMT. The time now is 07:03 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01061 seconds
  • Memory Usage 1,723KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete