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

Get a piece of xprofile metadata.


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



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


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


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

Default value: ''


(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


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


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;


Version Description
BuddyPress 1.5.0 Introduced.


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.