diff --git a/src/bp-groups/classes/class-bp-groups-member.php b/src/bp-groups/classes/class-bp-groups-member.php
index ba493fc3c..43a947e81 100644
a
|
b
|
class BP_Groups_Member { |
1369 | 1369 | groups_update_groupmeta( $group_id, 'total_member_count', groups_get_total_member_count( $group_id ) - 1 ); |
1370 | 1370 | |
1371 | 1371 | // If current user is the creator of a group and is the sole admin, delete that group to avoid counts going out-of-sync. |
1372 | | if ( groups_is_user_admin( $user_id, $group_id ) && count( groups_get_group_admins( $group_id ) ) < 2 && groups_is_user_creator( $user_id, $group_id ) ) |
1373 | | groups_delete_group( $group_id ); |
| 1372 | if ( groups_is_user_admin( $user_id, $group_id ) && count( groups_get_group_admins( $group_id ) ) < 2 ) { |
| 1373 | $admin = get_users( [ |
| 1374 | 'orderby' => 'ID', |
| 1375 | 'role' => bp_is_network_activated() ? 'manage_network_options' : 'manage_options', |
| 1376 | 'number' => 1, |
| 1377 | ] ); |
| 1378 | |
| 1379 | if ( ! isset( $admin[0] ) ) { |
| 1380 | return; |
| 1381 | } |
| 1382 | |
| 1383 | groups_join_group( $group_id, $admin[0]->ID ); |
| 1384 | groups_promote_member( $admin[0]->ID, $group_id, 'admin' ); |
| 1385 | } |
1374 | 1386 | } |
1375 | 1387 | |
1376 | 1388 | return $wpdb->query( $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d", $user_id ) ); |