好的,上面的代码确实有效,但对于超级管理员来说不行,您必须明确地从超级管理员中删除权限,如下所示:
// restrict super admin capabilites
add_filter(\'map_meta_cap\', \'restrict_super_admins\', 10, 4);
function restrict_super_admins($caps, $cap, $user_id, $args){
$super = array(
\'add_users\',
\'create_users\',
);
if( in_array($cap, $super) ) {
$caps[] = \'do_not_allow\';
}
return $caps;
}