• Hi,

    I’m working on a project at the moment that needs a section in the blogs sidebar that lists out the “Team” or authors and their job titles as a link to their author page. So it would look some thing like this…

    Mike – The Boss
    Ash – The Web Designer
    Simon – The Graphic Designer

    And so on.

    I have used <?php wp_list_authors(‘exclude_admin=1’); ?>, which list out all the authors, including admin even when changing 1 to 0 & back, but I can’t grab any extra info from this call.

    Does anyone have any ideas on how to do this?

Viewing 8 replies - 1 through 8 (of 8 total)
  • List users of blog

    <?php
    $blogusers = get_users_of_blog();
    if ($blogusers) {
    foreach ($blogusers as $bloguser) {
    $user = get_userdata($bloguser->user_id);
    //uncomment next line to see all values
    //echo "<pre>"; print_r($user); echo "</pre>";
    echo 'User ID ' . $user->ID . ' ' . $user->user_firstname . ' ' . $user->user_lastname ;
    }
    }
    ?>

    Thread Starter Ash

    (@ashbryant)

    Thanks MichaelH,

    But that’s not what I’m after. I would like to be able for the code to do something like this.

    look at the list of the authors. List those names & add some of their profile info along with their name.

    Like this.

    Mike – The Boss
    Ash – The Web Designer
    Simon – The Graphic Designer

    The job title could be stored in the surname field maybe as it’s not being used?

    Thread Starter Ash

    (@ashbryant)

    Sorry I have been dumb. That’s great thanks.

    Thread Starter Ash

    (@ashbryant)

    MichaelH,

    Any way to exclude a author by id from that?

    add something like this to exclude author id 1:

    if ($user->ID != '1' ) {
    echo 'User ID ' . $user->ID . ' ' . $user->user_firstname . ' ' . $user->user_lastname ;
    }

    Very usefull. Thank you very much ??

    How about the list_authors() ? When it that one supposed to be used?

    And further more:

    I am trying to reach the value of the capabilities but its empty.

    Can you see what I’ve done wrong?

    <?php
    
    $blogusers = get_users_of_blog();
    
    if ($blogusers) {
    	foreach ($blogusers as $bloguser) {
    		$user = get_userdata($bloguser->user_id);
    		//uncomment next line to see all values
    		echo "<pre>"; print_r($user); echo "</pre>";
    
    		$user_cap = $user->wp_capabilities;
    
    			echo 'User ID ' . $user->ID . ' ' . $user->user_firstname . ' ' . 
    
    $user->user_lastname . ' ' . $user_cap[0];
    
    	}
    }
    
    ?>

    Hey MichaelH,

    Better you should use this below code instead of checking the staic condition by user_id is 1.

    Since you might have more than one admin also on your blog.

    $isadmin = $wpdb->get_results("SELECT count(*) as count from $wpdb->usermeta WHERE user_id = $user->ID and meta_value=10");
    if ($isadmin[0]->count == 0 ) {
    //uncomment next line to see all values
    //echo "
    <pre>"; print_r($user); echo "</pre>
    ";
    echo 'User ID ' . $user->ID . ' ' . $user->user_firstname . ' ' . $user->user_lastname ;
    }
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to list authors?’ is closed to new replies.