| @@ 39-61 (lines=23) @@ | ||
| 36 | //@todo retry on failure |
|
| 37 | ||
| 38 | //try to choose a new master if we're demoting the current one |
|
| 39 | if ( $user_id == $master_user_id && 'administrator' != $role ) { |
|
| 40 | $query = new WP_User_Query( |
|
| 41 | array( |
|
| 42 | 'fields' => array( 'id' ), |
|
| 43 | 'role' => 'administrator', |
|
| 44 | 'orderby' => 'id', |
|
| 45 | 'exclude' => array( $master_user_id ), |
|
| 46 | ) |
|
| 47 | ); |
|
| 48 | $new_master = false; |
|
| 49 | foreach ( $query->results as $result ) { |
|
| 50 | $uid = absint( $result->id ); |
|
| 51 | if ( $uid && Jetpack::is_user_connected( $uid ) ) { |
|
| 52 | $new_master = $uid; |
|
| 53 | break; |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| 57 | if ( $new_master ) { |
|
| 58 | Jetpack_Options::update_option( 'master_user', $new_master ); |
|
| 59 | } |
|
| 60 | // else disconnect..? |
|
| 61 | } |
|
| 62 | } |
|
| 63 | } |
|
| 64 | } |
|
| @@ 1398-1420 (lines=23) @@ | ||
| 1395 | //@todo retry on failure |
|
| 1396 | ||
| 1397 | //try to choose a new master if we're demoting the current one |
|
| 1398 | if ( $user_id == $master_user_id && 'administrator' != $role ) { |
|
| 1399 | $query = new WP_User_Query( |
|
| 1400 | array( |
|
| 1401 | 'fields' => array( 'id' ), |
|
| 1402 | 'role' => 'administrator', |
|
| 1403 | 'orderby' => 'id', |
|
| 1404 | 'exclude' => array( $master_user_id ), |
|
| 1405 | ) |
|
| 1406 | ); |
|
| 1407 | $new_master = false; |
|
| 1408 | foreach ( $query->results as $result ) { |
|
| 1409 | $uid = absint( $result->id ); |
|
| 1410 | if ( $uid && Jetpack::is_user_connected( $uid ) ) { |
|
| 1411 | $new_master = $uid; |
|
| 1412 | break; |
|
| 1413 | } |
|
| 1414 | } |
|
| 1415 | ||
| 1416 | if ( $new_master ) { |
|
| 1417 | Jetpack_Options::update_option( 'master_user', $new_master ); |
|
| 1418 | } |
|
| 1419 | // else disconnect..? |
|
| 1420 | } |
|
| 1421 | } |
|
| 1422 | } |
|
| 1423 | ||