Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
12/06/2017 04:18:11 PM (7 years ago)
Author:
djpaul
Message:

Groups: add 'fields' parameter to BP_Groups_Group::get().

Allows return of only group IDs instead of entire objects when fields=ids is set, similiar to the fields parameter in WP_Query.

Fixes #7609

Props dcavins

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php

    r11737 r11762  
    22352235    }
    22362236
     2237    /**
     2238     * @group get_ids_only
     2239     */
     2240    public function test_get_return_ids_only() {
     2241        $now = time();
     2242        $g1 = $this->factory->group->create( array(
     2243            'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60 ),
     2244        ) );
     2245        $g2 = $this->factory->group->create( array(
     2246            'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60*2 ),
     2247        ) );
     2248        $g3 = $this->factory->group->create( array(
     2249            'last_activity' => date( 'Y-m-d H:i:s', $now - 60*60*3 ),
     2250        )  );
     2251
     2252        $groups = BP_Groups_Group::get( array(
     2253            'fields' => 'ids',
     2254        ) );
     2255
     2256        $this->assertSame( array( $g1, $g2, $g3 ), $groups['groups'] );
     2257    }
     2258
    22372259}
    22382260
Note: See TracChangeset for help on using the changeset viewer.