bp_get_user_meta_key( string|bool $key = false )

Get the meta_key for a given piece of user metadata


Description Description

BuddyPress stores a number of pieces of user data 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 Parameters

$key

(Optional) The usermeta meta_key.

Default value: false


Top ↑

Return Return

(string) $key The usermeta meta_key.


Top ↑

Source 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 1.5.0
	 *
	 * @param string $key The usermeta meta key.
	 */
	return apply_filters( 'bp_get_user_meta_key', $key );
}

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.