BP_Groups_Member::remove()

Remove the current membership.


Return Return

(bool) True on success, false on failure.


Source Source

File: bp-groups/classes/class-bp-groups-member.php

	public function remove() {
		global $wpdb;

		/**
		 * Fires before a member is removed from a group.
		 *
		 * @since 2.3.0
		 *
		 * @param BP_Groups_Member $this Current group membership object.
		 */
		do_action_ref_array( 'groups_member_before_remove', array( $this ) );

		$bp  = buddypress();
		$sql = $wpdb->prepare( "DELETE FROM {$bp->groups->table_name_members} WHERE user_id = %d AND group_id = %d", $this->user_id, $this->group_id );

		if ( !$result = $wpdb->query( $sql ) )
			return false;

		// Update the user's group count.
		self::refresh_total_group_count_for_user( $this->user_id );

		// Update the group's member count.
		self::refresh_total_member_count_for_group( $this->group_id );

		/**
		 * Fires after a member is removed from a group.
		 *
		 * @since 2.3.0
		 *
		 * @param BP_Groups_Member $this Current group membership object.
		 */
		do_action_ref_array( 'groups_member_after_remove', array( $this ) );

		return $result;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.