A fresh mix of code snippets and tutorials

Get all meta data for WordPress user

Quick tip to get all meta data for any WordPress user. Warning, arrays ahead..

Another useful tool to have in the box, here’s how to get the metadata associated with any user. Just add this snippet of code anywhere in your theme template:

$all_meta_for_user = get_user_meta( 17 );
print_r( $all_meta_for_user );

If placed outside the WordPress loop, replace 17 with any user ID; else, if used within the loop, a variable may be used for the user ID.

The results of this print_r dump will look something like this:

Array ( 
	[first_name]  => Array ( [0] => Capn ) 
	[last_name]   => Array ( [0] => Crunch ) 
	[nickname]    => Array ( [0] => The Capn ) 
	[description] => etc ...

To get at specific bits in this mess of arrays, use the following syntax:

$last_name = $all_meta_for_user['last_name'][0];

To learn more about this method, check out Getting all meta data at the WP Codex.

Learn more

WordPress Themes In Depth