WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 6 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

Your Answer


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.