WordPress at Your Fingertips

get_user_meta() WP 1.0

Retrieve user meta field for a user.

1 time — 0.000998 sec (slow) | 50000 times — 0.09 sec (speed of light) | PHP 7.1.2, WP 4.7.5

No Hooks.


Mixed. An array of values if $single is false. The value of meta data field if $single is true. False for an invalid $user_id (non-numeric, zero, or negative value). An empty string if a valid but non-existing user ID is passed.


get_user_meta( $user_id, $key, $single );
$user_id(int) (required)
User ID.
The meta key to retrieve. By default, returns data for all keys.
Whether to return a single value. This parameter has no effect if $key is not specified.
Default: false


Since 3.0.0 Introduced.

Code of get_user_meta() WP 5.8

function get_user_meta( $user_id, $key = '', $single = false ) {
	return get_metadata( 'user', $user_id, $key, $single );

From tag: Metadatas (any)

No comments
    Log In