Reputation: 12608
I am using 'get_users' to generate an array or all WordPress users with the role 'moderator', my code looks like this..
<?php
$args = array(
'fields' => 'first_name',
'role' => 'moderator'
);
$temp = get_users($args);
?>
<?php foreach ($temp as $i => $item): ?>
<input type="checkbox" name="<?php $mb->the_name(); ?>" value="<?php echo $item; ?>"<?php $mb->the_checkbox_state($item); ?>/> <?php echo $item; ?><br/>
<?php endforeach; ?>
This works but instead of returning the users first name it returns the users id. Does anybody know why this is happening?
Upvotes: 1
Views: 3417
Reputation: 5774
<?php
$args = array(
'fields' => 'first_name',
'role' => 'moderator'
);
$temp = get_users($args);
foreach($temp as $user) {
echo '<li>' . $user->display_name . '</li>';
}
?>
I believe this is what you're looking for.
These are the fields you can use instead of display_name
[ID] => 1
[user_login] => admin
[user_pass] => $P$Bxudi6gJMk2GRt2ed3xvZ06c1BPZXi/
[user_nicename] => admin
[user_email] => [email protected]
[user_url] => http://localhost/
[user_registered] => 2010-06-29 07:08:55
[user_activation_key] =>
[user_status] => 0
[display_name] => Richard Branson
Upvotes: 4