Skip to:
Content

BuddyPress.org

Changeset 12767


Ignore:
Timestamp:
10/24/2020 02:07:19 PM (6 years ago)
Author:
imath
Message:

Administration: improve bulk remove/assign Group Types

These functionalities now behave as follows :

  • Bulk removing group types is removing all assigned group types.
  • Bulk assigning a group type is replacing all assigned group types with the selected group type.

Props vapvarun

Fixes #8379

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-admin.php

    r12738 r12767  
    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                                         }
     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 ( ! $current_types || 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;
    13941398                                }
    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                                         }
    1402                                 }
     1399                                unset( $group_types );
    14031400                        }
    14041401                }
Note: See TracChangeset for help on using the changeset viewer.