Skip to:
Content

BuddyPress.org

Changeset 7237


Ignore:
Timestamp:
06/24/2013 06:59:22 PM (11 years ago)
Author:
boonebgorges
Message:

Adds is_confirmed param to BP_Group_Member_Query, defaulting to true

This additional parameter ensures that BP_Group_Member_Query distinguishes
between confirmed and unconfirmed members when pulling up lists of group
members.

Fixes #5072

Props Mike_Cowobo

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-groups/bp-groups-classes.php

    r7228 r7237  
    988988        // these defaults).
    989989        $this->query_vars = wp_parse_args( $this->query_vars, array(
    990             'group_id'   => 0,
    991             'group_role' => array( 'member' ),
     990            'group_id'     => 0,
     991            'group_role'   => array( 'member' ),
     992            'is_confirmed' => true,
    992993        ) );
    993994
     
    10271028        /** WHERE clauses *****************************************************/
    10281029
     1030        // Group id
    10291031        $sql['where'][] = $wpdb->prepare( "group_id = %d", $this->query_vars['group_id'] );
     1032
     1033        // is_confirmed
     1034        $is_confirmed = ! empty( $this->query_vars['is_confirmed'] ) ? 1 : 0;
     1035        $sql['where'][] = $wpdb->prepare( "is_confirmed = %d", $is_confirmed );
    10301036
    10311037        // Role information is stored as follows: admins have
  • trunk/tests/includes/testcase.php

    r7188 r7237  
    227227        $r = wp_parse_args( $args, array(
    228228            'date_modified' => bp_core_current_time(),
     229            'is_confirmed' => 1,
    229230        ) );
    230231
     
    236237        $new_member->user_title    = '';
    237238        $new_member->date_modified = $r['date_modified'];
    238         $new_member->is_confirmed  = 1;
     239        $new_member->is_confirmed  = $r['is_confirmed'];
    239240
    240241        $new_member->save();
  • trunk/tests/testcases/groups/class-bp-group-member-query.php

    r7145 r7237  
    299299    }
    300300
     301    public function test_confirmed_members() {
     302        $g = $this->factory->group->create();
     303        $u1 = $this->create_user();
     304        $u2 = $this->create_user();
     305
     306        $this->add_user_to_group( $u1, $g, array(
     307            'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
     308            'is_confirmed' => 0,
     309        ) );
     310
     311        $this->add_user_to_group( $u2, $g, array(
     312            'date_modified' => gmdate( 'Y-m-d H:i:s', $time - 100 ),
     313            'is_confirmed' => 1,
     314        ) );
     315
     316        $query_members = new BP_Group_Member_Query( array(
     317            'group_id' => $g,
     318        ) );
     319
     320        $ids = wp_parse_id_list( array_keys( $query_members->results ) );
     321        $this->assertEquals( array( $u2 ), $ids );
     322    }
     323
    301324}
Note: See TracChangeset for help on using the changeset viewer.