bp_get_user_meta_key( string|bool $key = false )

Get the meta_key for a given piece of user metadata

Description

BuddyPress stores a number of pieces of userdata in the WordPress central usermeta table. In order to allow plugins to enable multiple instances of BuddyPress on a single WP installation, BP’s usermeta keys are filtered through this function, so that they can be altered on the fly.

Plugin authors should use BP’s _user_meta() functions, which bakes in bp_get_user_meta_key(): $friend_count = bp_get_user_meta( $user_id, ‘total_friend_count’, true ); If you must use WP’s _user_meta() functions directly for some reason, you should use this function to determine the $key parameter, eg $friend_count = get_user_meta( $user_id, bp_get_user_meta_key( ‘total_friend_count’ ), true ); If using the WP functions, do not not hardcode your meta keys.

Parameters

$key

(string|bool) (Optional) The usermeta meta_key.

Default value: false

Return

(string) $key The usermeta meta_key.

Source

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

function bp_get_user_meta_key( $key = false ) {

	/**
	 * Filters the meta_key for a given piece of user metadata.
	 *
	 * @since BuddyPress 1.5.0
	 *
	 * @param string $key The usermeta meta key.
	 */
	return apply_filters( 'bp_get_user_meta_key', $key );
}

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.