diff --git src/bp-groups/bp-groups-admin.php src/bp-groups/bp-groups-admin.php
index 69662ec80..8542cf47c 100644
|
|
|
function bp_groups_admin_process_group_type_bulk_changes( $doaction ) { |
| 1382 | 1382 | $group_id = (int) $group_id; |
| 1383 | 1383 | |
| 1384 | 1384 | // Get the old group type to check against. |
| 1385 | | $group_type = bp_groups_get_group_type( $group_id ); |
| 1386 | | |
| 1387 | | if ( 'remove_group_type' === $new_type ) { |
| 1388 | | // Remove the current group type, if there's one to remove. |
| 1389 | | if ( $group_type ) { |
| 1390 | | $removed = bp_groups_remove_group_type( $group_id, $group_type ); |
| 1391 | | if ( false === $removed || is_wp_error( $removed ) ) { |
| 1392 | | $error = true; |
| 1393 | | } |
| 1394 | | } |
| 1395 | | } else { |
| 1396 | | // Set the new group type. |
| 1397 | | if ( $new_type !== $group_type ) { |
| 1398 | | $set = bp_groups_set_group_type( $group_id, $new_type ); |
| 1399 | | if ( false === $set || is_wp_error( $set ) ) { |
| 1400 | | $error = true; |
| 1401 | | } |
| | 1385 | $current_types = bp_groups_get_group_type( $group_id, false ); |
| | 1386 | |
| | 1387 | if ( $current_types && 'remove_group_type' === $new_type ) { |
| | 1388 | $group_types = array(); |
| | 1389 | } elseif ( 1 !== count( $current_types ) || $new_type !== $current_types[0] ) { |
| | 1390 | $group_types = array( $new_type ); |
| | 1391 | } |
| | 1392 | |
| | 1393 | // Set the new group type. |
| | 1394 | if ( isset( $group_types ) ) { |
| | 1395 | $set = bp_groups_set_group_type( $group_id, $group_types ); |
| | 1396 | if ( false === $set || is_wp_error( $set ) ) { |
| | 1397 | $error = true; |
| 1402 | 1398 | } |
| | 1399 | unset( $group_types ); |
| 1403 | 1400 | } |
| 1404 | 1401 | } |
| 1405 | 1402 | } |