[buddypress-dev] List of users with avatar (now list of First and Last names)

Wessel van Rensburg wildebees at gmail.com
Mon Jul 14 19:20:57 GMT 2008


Andy, I have tried the code below, and it works fine just out of the
box in a template. Thanks!

But instead of the User names, I would like for the First and Last
Name to display, as from the BP Profiles.  (To have a more Facebook
kind of experience where the actual name is important - rather than a
user name.)

How do I modify the code below to get a list of First and Last names?

regards Wessel


> On 8-Jul-08, at 10:05 AM, Brian L. Brey wrote:

> Anyone create code to display a list of members with their avatar
> and name (or similar)?

I'm working on the friends component right now, which will essentially
do this.

If you want to list members, you can just query the users table, and
then get their avatar and link based on their id.

<?php
$users = $wpdb->get_results ( $wpdb->prepare( "SELECT id FROM
wp_users" ) );
for ( $i = 0; $i < count($users); $i++ ) {
  $bp_users[] = array(
    'avatar' => xprofile_get_avatar( $users[$i]->id, 1 ),
    'link' => bp_core_get_userlink( $users[$i]->id )
  );
}
?>

Then you can loop through and do whatever you want with $bp_users:

<?php
 for ( $i = 0; $i < count($bp_users); $i++ ) {
   echo '<p>' . $bp_users[$i]['avatar'] . '</p>';
   echo '<p>' . $bp_users[$i]['link'] . '</p>';
 }
?>

I haven't tested or even tried that code, but it should work if I
haven't made any typos.

Andy

-- 
*

* Wessel van Rensburg
 ZuluZulu

 + 44 2071933026 (o)
 + 44 7530341889 (m)
 + 27 7658 71271

* wessel at zuluzulu.net
* Skype: wildebees
* http://zuluzulu.net


More information about the buddypress-dev mailing list