Changeset 33143
- Timestamp:
- 07/09/2015 04:15:30 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
src/wp-admin/includes/ms.php (modified) (1 diff)
-
tests/phpunit/tests/user/multisite.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ms.php
r33081 r33143 191 191 if ( !$user->exists() ) 192 192 return false; 193 194 // Global super-administrators are protected, and cannot be deleted. 195 $_super_admins = get_super_admins(); 196 if ( in_array( $user->user_login, $_super_admins, true ) ) { 197 return false; 198 } 199 193 200 /** 194 201 * Fires before a user is deleted from the network. -
trunk/tests/phpunit/tests/user/multisite.php
r32626 r33143 230 230 } 231 231 232 function test_revoked_super_admin_can_be_deleted() { 233 if ( isset( $GLOBALS['super_admins'] ) ) { 234 $old_global = $GLOBALS['super_admins']; 235 unset( $GLOBALS['super_admins'] ); 236 } 237 238 $user_id = $this->factory->user->create(); 239 grant_super_admin( $user_id ); 240 revoke_super_admin( $user_id ); 241 242 $this->assertTrue( wpmu_delete_user( $user_id ) ); 243 244 if ( isset( $old_global ) ) { 245 $GLOBALS['super_admins'] = $old_global; 246 } 247 } 248 249 function test_revoked_super_admin_is_deleted() { 250 if ( isset( $GLOBALS['super_admins'] ) ) { 251 $old_global = $GLOBALS['super_admins']; 252 unset( $GLOBALS['super_admins'] ); 253 } 254 255 $user_id = $this->factory->user->create(); 256 grant_super_admin( $user_id ); 257 revoke_super_admin( $user_id ); 258 wpmu_delete_user( $user_id ); 259 $user = new WP_User( $user_id ); 260 261 $this->assertFalse( $user->exists(), 'WP_User->exists' ); 262 263 if ( isset( $old_global ) ) { 264 $GLOBALS['super_admins'] = $old_global; 265 } 266 } 267 268 function test_super_admin_cannot_be_deleted() { 269 if ( isset( $GLOBALS['super_admins'] ) ) { 270 $old_global = $GLOBALS['super_admins']; 271 unset( $GLOBALS['super_admins'] ); 272 } 273 274 $user_id = $this->factory->user->create(); 275 grant_super_admin( $user_id ); 276 277 $this->assertFalse( wpmu_delete_user( $user_id ) ); 278 279 if ( isset( $old_global ) ) { 280 $GLOBALS['super_admins'] = $old_global; 281 } 282 } 283 232 284 /** 233 285 * @ticket 27205
Note: See TracChangeset
for help on using the changeset viewer.