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()?

1 Answer
1

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];

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *