Check if user is sysop [duplicate]

泄露秘密 提交于 2020-01-04 06:55:13

问题


How to check if user have sysop or other permission (in file LocalSettings.php or extension)?


回答1:


Ok found:

$wgHooks['ParserFirstCallInit'][] = 'ifUserSysop';
function ifUserSysop() {

    global $wgUser;

    if (in_array("sysop", $wgUser->getEffectiveGroups())) {
        // if sysop
    }

    if($wgUser->isLoggedIn()) {
        // is logged in
    }

    return true;

}

Full contents of $wgUser->getEffectiveGroups() for sysop:

Array
(
    [0] => bureaucrat
    [1] => editor
    [2] => sysop
    [3] => *
    [4] => user
)

For user:

Array
(
    [0] => *
    [1] => user
)

For anon:

Array
(
    [0] => *
)

More intresting things ($wgUser->isAnon(), isLoggedIn(), isBlocked()) available here



来源:https://stackoverflow.com/questions/17027076/check-if-user-is-sysop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!