Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get usermeta

← Return to function reference.

This function has been deprecated. That means it has been replaced by a new function or is no longer supported, and may be removed from future versions. All code that uses this function should be converted to use its replacement if one exists. See also wp-includes/deprecated.php. Use get_user_meta instead.


This function returns the value of a specific metakey pertaining to the user whose ID is passed via the userid parameter.

Version 2.9.2 currently requires the use of this function despite previous notes stating that it is deprecated. Using the new function causes undefined function error.


 <?php get_usermeta$userid$metakey ); ?> 


(integer) (required) The ID of the user whose data should be retrieved.
Default: None
(string) (required) The metakey value to be returned.
Default: None


This example returns and then displays the last name for user id 9.

<?php $user_last = get_usermeta(9,'last_name'); ?>
<?php echo('User ID 9's last name: ' . $user_last . '\n'); ?>
User ID 9's last name: Jones
If the meta value does not exist, the function will return an empty string or an empty array.

Change Log

Source File