bp_xprofile_add_meta( int $object_id, string $object_type, string $meta_key, mixed $meta_value, bool $unique = false )

Add a piece of xprofile metadata.


Description Description


Parameters Parameters

$object_id

(Required) ID of the object the metadata belongs to.

$object_type

(Required) Type of object. 'group', 'field', or 'data'.

$meta_key

(Required) Metadata key.

$meta_value

(Required) Metadata value.

$unique

(Optional) Whether to enforce a single metadata value for the given key. If true, and the object already has a value for the key, no change will be made.

Default value: false


Top ↑

Return Return

(int|bool) The meta ID on successful update, false on failure.


Top ↑

Source Source

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

function bp_xprofile_add_meta( $object_id, $object_type, $meta_key, $meta_value, $unique = false ) {
	add_filter( 'query', 'bp_filter_metaid_column_name' );
	add_filter( 'query', 'bp_xprofile_filter_meta_query' );
	$retval = add_metadata( 'xprofile_' . $object_type , $object_id, $meta_key, $meta_value, $unique );
	remove_filter( 'query', 'bp_filter_metaid_column_name' );
	remove_filter( 'query', 'bp_xprofile_filter_meta_query' );

	return $retval;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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