WordPress.org

Make WordPress Core

Changeset 14043


Ignore:
Timestamp:
04/09/2010 08:26:16 AM (8 years ago)
Author:
nacin
Message:

More grant/revoke super admin improvements. fixes #12933.

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ms.php

    r14042 r14043  
    819819        update_site_option( 'site_admins' , $super_admins );
    820820        do_action( 'granted_super_admin', $user_id );
    821     }
     821        return true;
     822    }
     823    return false;
    822824}
    823825
     
    831833    do_action( 'revoke_super_admin', $user_id );
    832834
    833     $admin_email = get_site_option( 'admin_email' );
    834835    $super_admins = get_site_option( 'site_admins', array( 'admin' ) );
    835 
    836836    $user = new WP_User( $user_id );
    837     if ( $user->user_email != $admin_email ) {
    838         foreach ( $super_admins as $key => $username ) {
    839             if ( $username == $user->user_login ) {
    840                 unset( $super_admins[$key] );
    841                 update_site_option( 'site_admins' , $super_admins );
    842                 do_action( 'revoked_super_admin', $user_id );
    843                 break;
    844             }
    845         }
    846     }
     837    if ( $user->user_email != get_site_option( 'admin_email' ) ) {
     838        if ( false !== ( $key = array_search( $user->user_login, $super_admins ) ) ) {
     839            unset( $super_admins[$key] );
     840            update_site_option( 'site_admins', $super_admins );
     841            do_action( 'revoked_super_admin', $user_id );
     842            return true;
     843        }
     844    }
     845    return false;
    847846}
    848847?>
  • trunk/wp-admin/user-edit.php

    r14003 r14043  
    122122        delete_user_meta( $user_id, $blog_prefix . 'capabilities' );
    123123
    124     if ( is_multisite() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) )
     124    if ( is_multisite() && !IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && empty( $_POST['super_admin'] ) == is_super_admin( $user_id ) )
    125125        empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id );
    126126}
Note: See TracChangeset for help on using the changeset viewer.