也许这个插件可以帮助:http://wordpress.org/extend/plugins/extended-super-admins/ 结合硬编码全局变量$super\\u admins,特定于每个站点。
它应该能够在加载站点管理菜单时在挂钩中进行设置,但还不确定如何实施。这似乎是一个很有希望的解决方案,很快我将不得不自己处理这个问题。
请参见:http://svn.automattic.com/wordpress/trunk/wp-admin/includes/ms.php 如果已经设置了全局$super\\u admins,请注意返回值。
/**
* Grants super admin privileges.
*
* @since 3.0.0
* @param int $user_id
*/
function grant_super_admin( $user_id ) {
global $super_admins;
// If global super_admins override is defined, there is nothing to do here.
if ( isset($super_admins) )
return false;
do_action( \'grant_super_admin\', $user_id );
// Directly fetch site_admins instead of using get_super_admins()
$super_admins = get_site_option( \'site_admins\', array( \'admin\' ) );
$user = new WP_User( $user_id );
if ( ! in_array( $user->user_login, $super_admins ) ) {
$super_admins[] = $user->user_login;
update_site_option( \'site_admins\' , $super_admins );
do_action( \'granted_super_admin\', $user_id );
return true;
}
return false;
}
/**
* Revokes super admin privileges.
*
* @since 3.0.0
* @param int $user_id
*/
function revoke_super_admin( $user_id ) {
global $super_admins;
// If global super_admins override is defined, there is nothing to do here.
if ( isset($super_admins) )
return false;
do_action( \'revoke_super_admin\', $user_id );
// Directly fetch site_admins instead of using get_super_admins()
$super_admins = get_site_option( \'site_admins\', array( \'admin\' ) );
$user = new WP_User( $user_id );
if ( $user->user_email != get_site_option( \'admin_email\' ) ) {
if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
unset( $super_admins[$key] );
update_site_option( \'site_admins\', $super_admins );
do_action( \'revoked_super_admin\', $user_id );
return true;
}
}
return false;
}