Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
09/21/2016 10:59:04 PM (5 years ago)
Author:
r-a-y
Message:

Groups: Add group type settings fields and a group type list on single group pages.

  • If group types are registered with the 'show_in_create_screen' parameter, group administrators can set the group type when creating a group or when on a group's "Manage > Settings" page.
  • If group types are registered with the 'show_in_list' parameter, a comma-delimited list of group types can be displayed for a group with the bp_group_type_list() function. By default, this function is used on a group page's header.

See #7210.

File:
1 edited

Legend:

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

    r11145 r11146  
    931931        if ( !check_admin_referer( 'groups_edit_group_settings' ) )
    932932            return false;
     933
     934        /*
     935         * Save group types.
     936         *
     937         * Ensure we keep types that have 'show_in_create_screen' set to false.
     938         */
     939        $current_types = bp_groups_get_group_type( bp_get_current_group_id(), false );
     940        $current_types = array_intersect( bp_groups_get_group_types( array( 'show_in_create_screen' => false ) ), (array) $current_types );
     941        if ( isset( $_POST['group-types'] ) ) {
     942            $current_types = array_merge( $current_types, $_POST['group-types'] );
     943
     944            // Set group types.
     945            bp_groups_set_group_type( bp_get_current_group_id(), $current_types );
     946
     947        // No group types checked, so this means we want to wipe out all group types.
     948        } else {
     949            /*
     950             * Passing a blank string will wipe out all types for the group.
     951             *
     952             * Ensure we keep types that have 'show_in_create_screen' set to false.
     953             */
     954            $current_types = empty( $current_types ) ? '' : $current_types;
     955
     956            // Set group types.
     957            bp_groups_set_group_type( bp_get_current_group_id(), $current_types );
     958        }
    933959
    934960        if ( !groups_edit_group_settings( $_POST['group-id'], $enable_forum, $status, $invite_status ) ) {
Note: See TracChangeset for help on using the changeset viewer.