[buddypress-dev] List of users with avatar
Andy Peatling
andypeatling at automattic.com
Tue Jul 8 17:28:59 GMT 2008
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
---------
Andy Peatling | Social Engineer | Automattic
http://andyinlife.com
More information about the buddypress-dev
mailing list