bp_xprofile_get_meta( int $object_id, string $object_type, string $meta_key = '', bool $single = true )

Get a piece of xprofile metadata.


Description Description

Note that the default value of $single is true, unlike in the case of the underlying get_metadata() function. This is for backward compatibility.


Top ↑

Parameters Parameters

$object_id

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

$object_type

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

$meta_key

(string) (Optional) Key of the metadata being fetched. If omitted, all metadata for the object will be retrieved.

Default value: ''

$single

(bool) (Optional) If true, return only the first value of the specified meta_key. This parameter has no effect if meta_key is not specified. Default: true.

Default value: true


Top ↑

Return Return

(mixed) Meta value if found. False on failure.


Source Source

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

function bp_xprofile_get_meta( $object_id, $object_type, $meta_key = '', $single = true ) {
	// Sanitize object type.
	if ( ! in_array( $object_type, array( 'group', 'field', 'data' ) ) ) {
		return false;
	}

	add_filter( 'query', 'bp_filter_metaid_column_name' );
	add_filter( 'query', 'bp_xprofile_filter_meta_query' );
	$retval = get_metadata( 'xprofile_' . $object_type, $object_id, $meta_key, $single );
	remove_filter( 'query', 'bp_filter_metaid_column_name' );
	remove_filter( 'query', 'bp_xprofile_filter_meta_query' );

	return $retval;
}


Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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