Function: get_user_meta

get_user_meta( integer $user_id, string $key, boolean $single )

Retrieve user meta field for a user.

Parameters

Name Type(s) Default Value Description
$user_id integer

User ID.

$key string ''

Optional. The meta key to retrieve. By default, returns data for all keys.

$single boolean false

Whether to return a single value.

Returns

mixed

Will be an array if $single is false. Will be value of meta data field if $single is true.

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.