I would like to retrieve the meta_values for an array of meta_keys for a user. Is there a function in WordPress core that offers this functionality? Something that would work like this:

$array_of_keys = array( 'key_1', 'another_key' );

$values = get_user_meta_array( $user_id, $array_of_keys );

And values would maybe be an array like this:

    'key_1'       => 'some value',
    'another_key' => 5,

I could easily write a custom function to do this, but I would rather do it 'the WordPress way' if there is one.



1 Answer 1


get_user_meta() with omitted key argument will return all data for the object.

Trying to retrieve metadata selectively is usually pointless optimization from performance point of view, since everything built on Metadata API tends to just query all data anyway and cache it (which in turn object cache plugin makes persistent and snappy).

  • Thanks, I think this is probably the best solution in my case.
    – J.D.
    Jun 2, 2013 at 21:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.