Ticket #39170: 39170.diff
File 39170.diff, 2.9 KB (added by , 8 years ago) |
---|
-
src/wp-admin/user-edit.php
364 364 </select></td></tr> 365 365 <?php endif; //!IS_PROFILE_PAGE 366 366 367 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>367 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && ! isset( $super_admins ) ) { ?> 368 368 <tr class="user-super-admin-wrap"><th><?php _e('Super Admin'); ?></th> 369 369 <td> 370 <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?>371 370 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.' ); ?></label></p> 372 <?php else : ?>373 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p>374 <?php endif; ?>375 371 </td></tr> 376 372 <?php } ?> 377 373 -
src/wp-includes/capabilities.php
769 769 * Revokes Super Admin privileges. 770 770 * 771 771 * @since 3.0.0 772 * @since 4.8.0 Super admin privileges can be revoked regardless of email address. 772 773 * 773 774 * @global array $super_admins 774 775 * … … 795 796 $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); 796 797 797 798 $user = get_userdata( $user_id ); 798 if ( $user && 0 !== strcasecmp( $user->user_email, get_site_option( 'admin_email' ) )) {799 if ( $user ) { 799 800 if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) { 800 801 unset( $super_admins[$key] ); 801 802 update_site_option( 'site_admins', $super_admins ); -
tests/phpunit/tests/user/multisite.php
424 424 425 425 $wp_roles->remove_role( $role ); 426 426 } 427 428 /** 429 * @ticket 39170 430 */ 431 public function test_revoke_super_admin_with_network_email() { 432 if ( isset( $GLOBALS['super_admins'] ) ) { 433 $old_global = $GLOBALS['super_admins']; 434 unset( $GLOBALS['super_admins'] ); 435 } 436 437 $old_network_email = get_site_option( 'admin_email' ); 438 439 $email_address = 'superadmin333@example.org'; 440 $user_id = self::factory()->user->create( array( 441 'user_email' => $email_address, 442 ) ); 443 grant_super_admin( $user_id ); 444 update_site_option( 'admin_email', $email_address ); 445 446 $result = revoke_super_admin( $user_id ); 447 448 update_site_option( 'admin_email', $old_network_email ); 449 450 if ( isset( $old_global ) ) { 451 $GLOBALS['super_admins'] = $old_global; 452 } 453 454 $this->assertTrue( $result ); 455 } 427 456 } 428 457 429 458 endif ;