Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
04/27/2015 07:10:10 PM (10 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.

File:
1 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 );
Note: See TracChangeset for help on using the changeset viewer.