I’m using this piece of code to list users and their information. The problem I’m having is that the description isn’t showing. Obviously it’s because the description lays under “user_meta” and not “users”. But how would I solve that?
<?php
$blogusers = get_users('include=2,3,4,5,6,7,8');
foreach ($blogusers as $user) {
echo '<li>'
. get_avatar($user->ID, 120) .
'<br />'
. $user->display_name .
'<br />'
. $user->user_email .
'<br />'
. $user->user_description .
'</li>';
}
?>
The Native get_users() function returns an array of user objects and each on holds
as you can see
user_description
is not a part of this object since it’s stored in a different table in the database(usermeta
as oppose tousers
).So Instead of
$user->user_description
useget_user_meta($user->ID, 'description', true)
Just in case anyone (just like me) comes across this thread, you can extend this to show custom fields.
Add this to your theme’s
functions.php
:then just add whatever fields you want to your
foreach
call, like:I hope this is ok to post here. It’s slightly off topic, but hopefully it helps (if not mods, please remove).