2

如何检查用户是否具有 sysop 或其他权限(在文件LocalSettings.php或扩展名中)?

4

1 回答 1

1

好的发现:

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

    global $wgUser;

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

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

    return true;

}

$wgUser->getEffectiveGroups()for sysop的完整内容:

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

对于用户:

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

对于匿名:

Array
(
    [0] => *
)

更多有趣的东西($wgUser->isAnon(), isLoggedIn(), isBlocked()在这里

于 2013-06-10T16:02:55.670 回答