1

I use $data = get_user_meta ( $user_id); to get all data. But only need some fields like gender - city - answer.

How can I filter this in get_user_meta()?

3

The function's arguments are as follows: user ID, custom field name (meta key), data return method (optional).

So if you wanted to grab data in usermeta with the key of 'member_zip_code', you would run:

get_user_meta( $user_id, 'member_zip_code', true );

Alternatively, in your prior method, you could grab the additional data like this:

$data = get_user_meta ( $user_id);

$data['member_zip_code'][0];

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.