query.get_user_meta

/ Database / query.get_user_meta

Title : query.get_user_meta
Purpose : For retrieving specific user meta data
Syntax :
Input Parameters : user_id: (int) (Required) User ID
key: (string) (Optional) The meta key to retrieve. By default, returns data for all keys. Default value: ”
single: (bool) (Optional) Whether to return a single value. This parameter has no effect if $key is not specified. Default value: false
Return Value : (mixed) An array if $single is false. The value of meta data field if $single is true. False for an invalid $user_id.
Example 1 :
Code :
Output : Displays the value of key “favourite_movie” if the key exist
Description : In this example we are passing USER_ID and a KEY, so if a record exist wrt the USER_ID and a KEY then it will return the value. If we are not passing KEY then it will return an ARRAY of all the user meta of the respective user.
Categories
Most Popular

Leave a Reply

Your email address will not be published.