@@ 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 | } |
@@ 1272-1294 (lines=23) @@ | ||
1269 | //@todo retry on failure |
|
1270 | ||
1271 | //try to choose a new master if we're demoting the current one |
|
1272 | if ( $user_id == $master_user_id && 'administrator' != $role ) { |
|
1273 | $query = new WP_User_Query( |
|
1274 | array( |
|
1275 | 'fields' => array( 'id' ), |
|
1276 | 'role' => 'administrator', |
|
1277 | 'orderby' => 'id', |
|
1278 | 'exclude' => array( $master_user_id ), |
|
1279 | ) |
|
1280 | ); |
|
1281 | $new_master = false; |
|
1282 | foreach ( $query->results as $result ) { |
|
1283 | $uid = absint( $result->id ); |
|
1284 | if ( $uid && Jetpack::is_user_connected( $uid ) ) { |
|
1285 | $new_master = $uid; |
|
1286 | break; |
|
1287 | } |
|
1288 | } |
|
1289 | ||
1290 | if ( $new_master ) { |
|
1291 | Jetpack_Options::update_option( 'master_user', $new_master ); |
|
1292 | } |
|
1293 | // else disconnect..? |
|
1294 | } |
|
1295 | } |
|
1296 | } |
|
1297 |