Index: src/wp-admin/user-edit.php
===================================================================
--- src/wp-admin/user-edit.php (revision 39541)
+++ src/wp-admin/user-edit.php (working copy)
@@ -364,14 +364,10 @@
+if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && ! isset( $super_admins ) ) { ?>
|
-user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?>
-
-
-
|
Index: src/wp-includes/capabilities.php
===================================================================
--- src/wp-includes/capabilities.php (revision 39541)
+++ src/wp-includes/capabilities.php (working copy)
@@ -769,6 +769,7 @@
* Revokes Super Admin privileges.
*
* @since 3.0.0
+ * @since 4.8.0 Super admin privileges can be revoked regardless of email address.
*
* @global array $super_admins
*
@@ -795,7 +796,7 @@
$super_admins = get_site_option( 'site_admins', array( 'admin' ) );
$user = get_userdata( $user_id );
- if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) ) ) {
+ if ( $user ) {
if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
unset( $super_admins[$key] );
update_site_option( 'site_admins', $super_admins );
Index: tests/phpunit/tests/user/multisite.php
===================================================================
--- tests/phpunit/tests/user/multisite.php (revision 39541)
+++ tests/phpunit/tests/user/multisite.php (working copy)
@@ -424,6 +424,35 @@
$wp_roles->remove_role( $role );
}
+
+ /**
+ * @ticket 39170
+ */
+ public function test_revoke_super_admin_with_network_email() {
+ if ( isset( $GLOBALS['super_admins'] ) ) {
+ $old_global = $GLOBALS['super_admins'];
+ unset( $GLOBALS['super_admins'] );
+ }
+
+ $old_network_email = get_site_option( 'admin_email' );
+
+ $email_address = 'superadmin333@example.org';
+ $user_id = self::factory()->user->create( array(
+ 'user_email' => $email_address,
+ ) );
+ grant_super_admin( $user_id );
+ update_site_option( 'admin_email', $email_address );
+
+ $result = revoke_super_admin( $user_id );
+
+ update_site_option( 'admin_email', $old_network_email );
+
+ if ( isset( $old_global ) ) {
+ $GLOBALS['super_admins'] = $old_global;
+ }
+
+ $this->assertTrue( $result );
+ }
}
endif ;