More grant/revoke super admin improvements. fixes #12933.
git-svn-id: http://svn.automattic.com/wordpress/trunk@14043 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6eaa3b9637
commit
bf77b5c189
|
@ -818,7 +818,9 @@ function grant_super_admin( $user_id ) {
|
|||
$super_admins[] = $user->user_login;
|
||||
update_site_option( 'site_admins' , $super_admins );
|
||||
do_action( 'granted_super_admin', $user_id );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -830,19 +832,16 @@ function grant_super_admin( $user_id ) {
|
|||
function revoke_super_admin( $user_id ) {
|
||||
do_action( 'revoke_super_admin', $user_id );
|
||||
|
||||
$admin_email = get_site_option( 'admin_email' );
|
||||
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
|
||||
|
||||
$user = new WP_User( $user_id );
|
||||
if ( $user->user_email != $admin_email ) {
|
||||
foreach ( $super_admins as $key => $username ) {
|
||||
if ( $username == $user->user_login ) {
|
||||
unset( $super_admins[$key] );
|
||||
update_site_option( 'site_admins' , $super_admins );
|
||||
do_action( 'revoked_super_admin', $user_id );
|
||||
break;
|
||||
}
|
||||
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;
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -121,7 +121,7 @@ if ( !is_multisite() ) {
|
|||
if ( $delete_role ) // stops users being added to current blog when they are edited
|
||||
delete_user_meta( $user_id, $blog_prefix . 'capabilities' );
|
||||
|
||||
if ( is_multisite() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) )
|
||||
if ( is_multisite() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
|
||||
empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue