Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

For some reason this is not working for me :(

$get_members = array(
    'blog_id' => $GLOBALS['blog_id'],
    'role' => 'sm_flagar',
);

$blogusers = get_users($get_members);
    foreach ($blogusers as $user) {
        echo "<li><a href=\"".$user->user_url."\">". $user->first_name ." ". $user->last_name ."</a></li>";
    }
share|improve this question

1 Answer 1

up vote 3 down vote accepted

first_name and last_name are stored in the usermeta table. Therefore you have to use get_user_meta() to return these data. Try this code snippet:

$users = get_users(array(
    // blog_id is not required and will be set by WP_User
    'role' => 'sm_flagar'
));

foreach ($users as $user) {
    $firstName = get_user_meta($user->ID, 'first_name', true);
    $lastName = get_user_meta($user->ID, 'last_name', true);

    echo '<li><a href="' . $user->user_url . '">' . $firstName . ' ' . $lastName . '</a></li>' . PHP_EOL;
}
share|improve this answer
    
to the point answer. –  booota Sep 22 '11 at 7:54
    
excellent it works like a charm! :) –  ingvi Sep 22 '11 at 8:31
    
@ingvi Please accept the answer so it wouldn't stay open the hole time. –  rofflox Sep 22 '11 at 8:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.