Skip to:
Content

BuddyPress.org

Ticket #8379: 8379.patch

File 8379.patch, 1.5 KB (added by imath, 5 years ago)
  • src/bp-groups/bp-groups-admin.php

    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 ) { 
    13821382                        $group_id = (int) $group_id;
    13831383
    13841384                        // 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;
    14021398                                }
     1399                                unset( $group_types );
    14031400                        }
    14041401                }
    14051402        }