更新时间:2023-11-30 15:18:22
* blackops_programmer *给出的答案中的代码检查用户是否可以保护页面.默认情况下,这将是sysops,但是可以从任何组中分配或删除该权限.
The code in the answer by *blackops_programmer* checks whether the user can protect pages. Per default, that would be sysops, but the permission can be assigned or removed from any group.
如果您要执行的操作取决于保护页面的权限,则检查权限是正确的方法(除非您应使用$ this-> getUser(),而不是$ wgUser). 但是,如果您确实要检查sysop组,请使用以下命令:
If what you want to do depends on the right to protect pages, then checking the permission is the correct way (except you should use $this->getUser(), not $wgUser). However, if you really want to check for the sysop group, use this:
if ( in_array( 'sysop', $this->getUser()->getEffectiveGroups() ) {
echo 'Hello People';
}