groups_delete_groupmeta( int $group_id, string|bool $meta_key = false, string|bool $meta_value = false, bool $delete_all = false )

Delete metadata for a group.

Description

Parameters

$group_id

(Required) ID of the group.

$meta_key

(Optional) The key of the row to delete.

Default value: false

$meta_value

(Optional) Metadata value. If specified, only delete metadata entries with this value.

Default value: false

$delete_all

(Optional) If true, delete matching metadata entries for all groups. Otherwise, only delete matching metadata entries for the specified group. Default: false.

Default value: false

Return

(bool) True on success, false on failure.

Source

File: bp-groups/bp-groups-functions.php

function groups_delete_groupmeta( $group_id, $meta_key = false, $meta_value = false, $delete_all = false ) {
	global $wpdb;

	// Legacy - if no meta_key is passed, delete all for the item.
	if ( empty( $meta_key ) ) {
		$keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->groupmeta} WHERE group_id = %d", $group_id ) );

		// With no meta_key, ignore $delete_all.
		$delete_all = false;
	} else {
		$keys = array( $meta_key );
	}

	add_filter( 'query', 'bp_filter_metaid_column_name' );

	$retval = true;
	foreach ( $keys as $key ) {
		$retval = delete_metadata( 'group', $group_id, $key, $meta_value, $delete_all );
	}

	remove_filter( 'query', 'bp_filter_metaid_column_name' );

	return $retval;
}

Changelog

Changelog
Version Description
BuddyPress 1.0.0 Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.