With get_users() I am listing users and their information. I've a custom field in the database, people_lists_class.
<?php
$blogusers = get_users('role=contributor&orderby=display_name');
foreach ($blogusers as $user) {
echo
'<li class="person member">' .
'<a href="' . get_author_posts_url($user->ID, $author_nicename) . '">' .
'<div class="user-thumbnail alignleft">' .
get_avatar($user->ID, 50) .
'</div>' .
'</a>' .
/* \/ \/ \/ Look at this: \/ \/ \/ */
'<a href="' . get_author_posts_url($user->ID, $author_nicename) . '">' .
'<h5 class="user-name user-info">' .
$user->display_name . ', ' . get_user_meta($user->ID, 'people_lists_class', true) .
'</h5>' .
'</a>' .
/* /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ /\ */
'<p class="user-title user-info">' .
get_user_meta($user->ID, 'people_lists_title', true) .
'</p>' .
'<p class="user-bio user-info">' .
get_user_meta($user->ID, 'description', true) .
'</p>' .
'<a href="' . get_author_posts_url($user->ID, $author_nicename) . '">' .
'<p class="user-permalink user-info">' .
' View articles by ' . $user->display_name .
'</p>' .
'</a>' .
'<div class="clear"></div>' .
'</li>';
}
?>
To separate 'people_list_class' from 'display_name' I have a comma. But I only want the comma to show if the user have something written in the "people_lists_class"-field. Can I somehow integrate the following piece of code to accomplish this?
<?php if ( !empty( $user->people_lists_class ) ) {
echo ', ';
}
else {
echo '';
}
?>