More grant/revoke super admin improvements. fixes #12933.
git-svn-id: https://develop.svn.wordpress.org/trunk@14043 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
213aca7b04
commit
acb76fe42d
|
@ -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 ) {
|
||||
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 );
|
||||
break;
|
||||
}
|
||||
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