最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

user meta - how to get specific fields from get_user_meta()

matteradmin4PV0评论

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

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

Share Improve this question edited Jul 2, 2016 at 5:14 Mark Kaplun 23.8k7 gold badges43 silver badges65 bronze badges asked Jul 1, 2016 at 14:20 HermantsHermants 5014 gold badges7 silver badges19 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 9

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];
Post a comment

comment list (0)

  1. No comments so far