[buddypress-dev] List of users with avatar
Andy Peatling
andypeatling at automattic.com
Tue Jul 8 17:37:02 GMT 2008
You'll also need to add:
<?php global $wpdb; ?>
before that code if you put this in page template.
Andy
On 8-Jul-08, at 10:28 AM, Andy Peatling wrote:
> 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
>
>
>
> _______________________________________________
> buddypress-dev mailing list
> buddypress-dev at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/buddypress-dev
More information about the buddypress-dev
mailing list