function bp_group_management_delete_group($group_id) { global $bp; $group = new BP_Groups_Group($group_id); if (!$group->delete()) { return false; } /* Delete all group activity from activity streams */ if (function_exists('bp_activity_delete_by_item_id')) { bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id)); } // Remove all outstanding invites for this group groups_delete_all_group_invites($group_id); // Remove all notifications for any user belonging to this group bp_core_delete_all_notifications_by_type($group_id, $bp->groups->slug); do_action('groups_delete_group', $group_id); return true; }
/** * Delete a group and all of its associated metadata. * * @since 1.0.0 * * @param int $group_id ID of the group to delete. * * @return bool True on success, false on failure. */ function groups_delete_group($group_id) { /** * Fires before the deletion of a group. * * @since 1.5.0 * * @param int $group_id ID of the group to be deleted. */ do_action('groups_before_delete_group', $group_id); // Get the group object $group = groups_get_group(array('group_id' => $group_id)); // Bail if group cannot be deleted if (!$group->delete()) { return false; } // Remove all outstanding invites for this group groups_delete_all_group_invites($group_id); /** * Fires after the deletion of a group. * * @since 1.0.0 * * @param int $group_id ID of the group that was deleted. */ do_action('groups_delete_group', $group_id); return true; }
/** * Delete a group and all of its associated meta * * @global object $bp BuddyPress global settings * @param int $group_id * @since BuddyPress (1.0) */ function groups_delete_group($group_id) { global $bp; // Check the user is the group admin. if (!bp_is_item_admin()) { return false; } do_action('groups_before_delete_group', $group_id); // Get the group object $group = groups_get_group(array('group_id' => $group_id)); if (!$group->delete()) { return false; } // Delete all group activity from activity streams if (bp_is_active('activity')) { bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id)); } // Remove all outstanding invites for this group groups_delete_all_group_invites($group_id); // Remove all notifications for any user belonging to this group bp_core_delete_all_notifications_by_type($group_id, $bp->groups->id); do_action('groups_delete_group', $group_id); return true; }
/** * @group groups_delete_all_group_invites * @group group_invitations * @group group_membership */ public function test_groups_delete_all_group_invites() { $u1 = $this->factory->user->create(); $u2 = $this->factory->user->create(); $u3 = $this->factory->user->create(); $g1 = $this->factory->group->create(array('creator_id' => $u1)); self::invite_user_to_group($u2, $g1, $u1); self::invite_user_to_group($u3, $g1, $u1); groups_delete_all_group_invites($g1); // Get group invitations of any type, from any user in the group. $invitees = new BP_Group_Member_Query(array('group_id' => $g1, 'is_confirmed' => 0, 'invite_sent' => null, 'inviter_id' => 'any')); $this->assertTrue(empty($invitees->results)); }
/** * Delete a group and all of its associated metadata. * * @since BuddyPress (1.0.0) * * @param int $group_id ID of the group to delete. * @return bool True on success, false on failure. */ function groups_delete_group($group_id) { do_action('groups_before_delete_group', $group_id); // Get the group object $group = groups_get_group(array('group_id' => $group_id)); // Bail if group cannot be deleted if (!$group->delete()) { return false; } // Remove all outstanding invites for this group groups_delete_all_group_invites($group_id); do_action('groups_delete_group', $group_id); return true; }
/** * Delete a group and all of its associated meta * * @global object $bp BuddyPress global settings * @param int $group_id * @since 1.0 */ function groups_delete_group($group_id) { global $bp; // Check the user is the group admin. if (!$bp->is_item_admin) { return false; } // Get the group object $group = new BP_Groups_Group($group_id); if (!$group->delete()) { return false; } do_action('groups_before_delete_group', $group_id); // Delete all group activity from activity streams if (bp_is_active('activity')) { bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id)); } // Remove all outstanding invites for this group groups_delete_all_group_invites($group_id); // Remove all notifications for any user belonging to this group bp_core_delete_all_notifications_by_type($group_id, $bp->groups->id); // Remove forum if component is active and current group has one if (bp_is_active('forums') && ($forum_id = groups_get_groupmeta($group_id, 'forum_id'))) { do_action('bbpress_init'); bb_delete_forum($forum_id); } do_action('groups_delete_group', $group_id); return true; }
function groups_delete_group($group_id) { global $bp; /* Check the nonce first. */ if (!check_admin_referer('groups_delete_group')) { return false; } // Check the user is the group admin. if (!$bp->is_item_admin) { return false; } // Get the group object $group = new BP_Groups_Group($group_id); if (!$group->delete()) { return false; } // Remove the activity stream item groups_delete_activity(array('item_id' => $group_id, 'component_name' => $bp->groups->slug, 'component_action' => 'created_group', 'user_id' => $bp->loggedin_user->id)); // Remove all outstanding invites for this group groups_delete_all_group_invites($group_id); // Remove all notifications for any user belonging to this group bp_core_delete_all_notifications_by_type($group_id, $bp->groups->slug); do_action('groups_delete_group', $group_id); return true; }
/** * When a blog is spammed, archived, or deleted, delete the corresponding group * * @param int */ function thatcamp_delete_group_for_blog($blog_id) { global $bp; $group_id = thatcamp_get_blog_group($blog_id); // do it manually, to avoid groups_delete_group() cap check do_action('groups_before_delete_group', $group_id); // Get the group object $group = groups_get_group(array('group_id' => $group_id)); if (!$group->delete()) { return false; } // Delete all group activity from activity streams if (bp_is_active('activity')) { bp_activity_delete_by_item_id(array('item_id' => $group_id, 'component' => $bp->groups->id)); } // Remove all outstanding invites for this group groups_delete_all_group_invites($group_id); // Remove all notifications for any user belonging to this group bp_core_delete_all_notifications_by_type($group_id, $bp->groups->id); do_action('groups_delete_group', $group_id); }