Skip to:
Content

BuddyPress.org

Changeset 9811


Ignore:
Timestamp:
04/27/2015 07:10:10 PM (9 years ago)
Author:
dcavins
Message:

Use groups_remove_member in groups_leave_group.

Also change groups_remove_member() to allow it
to work in situations where bp_is_item_admin
may not be true.

See #6209.

Location:
trunk
Files:
2 edited

Legend:

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

    r9810 r9811  
    432432    }
    433433
    434     // This is exactly the same as deleting an invite, just is_confirmed = 1 NOT 0.
    435     if ( !groups_uninvite_user( $user_id, $group_id ) ) {
     434    if ( ! groups_remove_member( $user_id, $group_id ) ) {
    436435        return false;
    437436    }
     
    14061405function groups_remove_member( $user_id, $group_id ) {
    14071406
    1408     if ( ! bp_is_item_admin() )
    1409         return false;
     1407    if ( ! bp_is_item_admin() ) {
     1408        // bp_is_item_admin may not be set if this function is called outside of group context.
     1409        // Site admins and group admins can remove a member from a group.
     1410        // A member may also request to remove herself from a group.
     1411        if ( ! current_user_can( 'bp_moderate' )
     1412            && ! groups_is_user_admin( bp_loggedin_user_id(), $group_id )
     1413            && $user_id != bp_loggedin_user_id() ) {
     1414                return false;
     1415            }
     1416    }
    14101417
    14111418    $member = new BP_Groups_Member( $user_id, $group_id );
  • trunk/tests/phpunit/testcases/groups/functions.php

    r9654 r9811  
    3838        groups_join_group( $g2, $u2 );
    3939
     40        // Set the current user so the leave group request goes through.
     41        $this->set_current_user( $u2 );
    4042        groups_leave_group( $g1, $u2 );
    4143        $this->assertEquals( 1, bp_get_user_meta( $u2, 'total_group_count', true ) );
Note: See TracChangeset for help on using the changeset viewer.