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

Get a piece of xprofile metadata.

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.

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

Return

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

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;
}

Changelog

Changelog
Version Description
BuddyPress 1.5.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.