get_user_meta()
18th January 2021
0 Comments
Framework / CMS
WordPress [Version: Since 3.0.0]
Syntax
Typical Usage
Returns the user meta field for a given user in WordPress.
Accepted Parameters
- user_id (integer) (Required): The ID for the user you need to get the meta for.
- key (string) (Optional): The key for the meta you need to lookup. Leaving the key parameter blank will retrieve values for all meta keys.
- single (boolean) (Optional): Whether or not to return a single value.
Return Value(s)
Returns an array if $single is false, the value of the meta field if $single is true and false for an invalid $user_id.Notes
The $single parameter has no effect if $key is not specified.
Examples of get_user_meta()
Example 1
<?php
get_user_meta( $user_id, 'first_name', true )
Used In Projects
Was This Helpful?
If this post has helped you, please let me know. Your feedback will be highly appreciated and will help me build better content.