Skip to:
Content

BuddyPress.org

Changeset 11740


Ignore:
Timestamp:
11/03/2017 09:17:04 PM (2 years ago)
Author:
boonebgorges
Message:

Better parsing of params passed to groups_create_group().

This changeset rewrites the logic of the way default values are parsed,
so that values aren't inadvertently reset when updating an existing
group via groups_create_group().

Props dcavins.
Fixes #7619.

File:
1 edited

Legend:

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

    r11735 r11740  
    105105        'description'  => '',
    106106        'slug'         => '',
    107         'status'       => 'public',
    108         'parent_id'    => 0,
    109         'enable_forum' => 0,
    110         'date_created' => bp_core_current_time()
     107        'status'       => null,
     108        'parent_id'    => null,
     109        'enable_forum' => null,
     110        'date_created' => null
    111111    );
    112112
     
    121121        $creator_id  = ! empty( $creator_id ) ? $creator_id : $group->creator_id;
    122122        $description = ! empty( $description ) ? $description : $group->description;
     123        $status = ! is_null( $status ) ? $status : $group->status;
     124        $parent_id = ! is_null( $parent_id ) ? $parent_id : $group->parent_id;
     125        $enable_forum = ! is_null( $enable_forum ) ? $enable_forum : $group->enable_forum;
     126        $date_created = ! is_null( $date_created ) ? $date_created : $group->date_created;
    123127
    124128        // Groups need at least a name.
     
    131135        // Instantiate new group object.
    132136        $group = new BP_Groups_Group;
     137
     138        // Check for null values, reset to sensible defaults.
     139        $status = ! is_null( $status ) ? $status : 'public';
     140        $parent_id = ! is_null( $parent_id ) ? $parent_id : 0;
     141        $enable_forum = ! is_null( $enable_forum ) ? $enable_forum : 0;
     142        $date_created = ! is_null( $date_created ) ? $date_created : bp_core_current_time();
    133143    }
    134144
Note: See TracChangeset for help on using the changeset viewer.