Ticket #6597: 6597.groups_remove_member_tweaks.patch
File 6597.groups_remove_member_tweaks.patch, 3.1 KB (added by , 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..2af2773 100644
function groups_leave_group( $group_id, $user_id = 0 ) { 440 440 } 441 441 } 442 442 443 if ( ! groups_remove_member( $user_id, $group_id ) ) {443 if ( ! groups_remove_member( $user_id, $group_id, 'leave_group' ) ) { 444 444 return false; 445 445 } 446 446 447 447 bp_core_add_message( __( 'You successfully left the group.', 'buddypress' ) ); 448 448 449 /**450 * Fires after a user leaves a group.451 *452 * @since BuddyPress (1.0.0)453 *454 * @param int $group_id ID of the group.455 * @param int $user_id ID of the user leaving the group.456 */457 do_action( 'groups_leave_group', $group_id, $user_id );458 459 449 return true; 460 450 } 461 451 … … function groups_unban_member( $user_id, $group_id ) { 1427 1417 /** 1428 1418 * Remove a member from a group. 1429 1419 * 1430 * @param int $user_id ID of the user. 1431 * @param int $group_id ID of the group. 1420 * @param int $user_id ID of the user. 1421 * @param int $group_id ID of the group. 1422 * @param string $context Optional. Context of removal. Default: 'remove'. If passed, this will fire 1423 * a hook named after $context when a group member is removed succesfully. 1432 1424 * 1433 1425 * @return bool True on success, false on failure. 1434 1426 */ 1435 function groups_remove_member( $user_id, $group_id ) {1427 function groups_remove_member( $user_id, $group_id, $context = 'remove' ) { 1436 1428 1437 1429 if ( ! bp_is_item_admin() ) { 1438 1430 // 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 ) { 1447 1439 1448 1440 $member = new BP_Groups_Member( $user_id, $group_id ); 1449 1441 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 ); 1442 // Backward compatibility hook. 1443 if ( 'remove' === $context ) { 1444 /** 1445 * Fires before the removal of a member from a group. 1446 * 1447 * @todo We should deprecate this and direct devs to use the 1448 * 'groups_member_before_remove' hook instead. 1449 * 1450 * @since BuddyPress (1.2.6) 1451 * 1452 * @param int $group_id ID of the group being removed from. 1453 * @param int $user_id ID of the user being removed. 1454 */ 1455 do_action( "groups_remove_member", $group_id, $user_id ); 1456 1457 } 1458 1459 $retval = $member->remove(); 1460 1461 if ( false !== $retval && ! empty( $context ) && 'remove' !== $context ) { 1462 /** 1463 * Dynamic hook that fires after a group member is removed successfully. 1464 * 1465 * Hook name is derived from the $context parameter. 1466 * 1467 * @since 2.4.0 1468 * 1469 * @param int $group_id ID of the group being removed from. 1470 * @param int $user_id ID of the user being removed. 1471 */ 1472 do_action( "groups_{$context}", $group_id, $user_id ); 1473 1474 } 1459 1475 1460 return $ member->remove();1476 return $retval; 1461 1477 } 1462 1478 1463 1479 /** Group Membership **********************************************************/