Skip to:
Content

BuddyPress.org

Ticket #6597: 6597.2.patch

File 6597.2.patch, 2.0 KB (added by thebrandonallen, 9 years ago)
  • src/bp-groups/bp-groups-functions.php

    diff --git src/bp-groups/bp-groups-functions.php src/bp-groups/bp-groups-functions.php
    index a65f82d..3d158da 100644
    function groups_leave_group( $group_id, $user_id = 0 ) { 
    440440                }
    441441        }
    442442
    443         if ( ! groups_remove_member( $user_id, $group_id ) ) {
     443        if ( ! groups_remove_member( $user_id, $group_id, true ) ) {
    444444                return false;
    445445        }
    446446
    function groups_unban_member( $user_id, $group_id ) { 
    14271427/**
    14281428 * Remove a member from a group.
    14291429 *
    1430  * @param int $user_id  ID of the user.
    1431  * @param int $group_id ID of the group.
     1430 * @param int  $user_id  ID of the user.
     1431 * @param int  $group_id ID of the group.
     1432 * @param bool $_leave_group FOR INTERNAL USE ONLY! Is the user leaving a group?
    14321433 *
    14331434 * @return bool True on success, false on failure.
    14341435 */
    1435 function groups_remove_member( $user_id, $group_id ) {
     1436function groups_remove_member( $user_id, $group_id, $_leave_group = false ) {
    14361437
    14371438        if ( ! bp_is_item_admin() ) {
    14381439                // bp_is_item_admin may not be set if this function is called outside of group context.
    function groups_remove_member( $user_id, $group_id ) { 
    14471448
    14481449        $member = new BP_Groups_Member( $user_id, $group_id );
    14491450
    1450         /**
    1451          * Fires before the removal of a member from a group.
    1452          *
    1453          * @since BuddyPress (1.2.6)
    1454          *
    1455          * @param int $group_id ID of the group being removed from.
    1456          * @param int $user_id  ID of the user being removed.
    1457          */
    1458         do_action( 'groups_remove_member', $group_id, $user_id );
     1451        if ( false === $_leave_group ) {
     1452                /**
     1453                 * Fires before the removal of a member from a group. This action will not be
     1454                 * fired if we're calling `groups_remove_member()` via `groups_leave_group()`.
     1455                 *
     1456                 * @since BuddyPress (1.2.6)
     1457                 *
     1458                 * @see https://buddypress.trac.wordpress.org/ticket/6597
     1459                 *
     1460                 * @param int $group_id ID of the group being removed from.
     1461                 * @param int $user_id  ID of the user being removed.
     1462                 */
     1463                do_action( 'groups_remove_member', $group_id, $user_id );
     1464        }
    14591465
    14601466        return $member->remove();
    14611467}