Show users buddies on their profile

j0k3z - March 26, 2007 - 14:05
Project:Buddylist
Version:5.x-1.x-dev
Component:User interface
Category:feature request
Priority:critical
Assigned:Unassigned
Status:active
Description

Cant seem to get a buddylist snippet to show a users buddies on their profile.

I found this snippet but it only shows the buddies of the logged in user. How can I show the buddies of the person whos profile you are viewing?

[code]

<?php
if ( user_access('view buddy lists') || user_access('administer users') ) {
// if thisuser has friends, show friends
$output = '';
$i = 0;
$cnt = variable_get('buddylist_prof_buddies', 6);
if (
$buddies = buddylist_get_buddies($user->uid)) {
foreach(
array_keys($buddies) as $buddy) {
$account = user_load(array('uid' => $buddy));
$output .=theme('user_picture', $account);
$listbuddies[] = $account;
$i++;
if (
$i > $cnt) {
break;
}
}
$output .=  theme('user_list', $listbuddies);
if (
count($buddies) > variable_get('buddylist_prof_buddies', 5)) {
$output .= '<div class="more-link">' . l(t('more'), 'buddylist', array('title' => t('View more.'))) . '</div>';
}

print
$output;
}
}
?>

[/code]

#1

Rosamunda - April 5, 2008 - 19:20

I have exactly the same question!
I don´t get why anyone should want to see their very own buddies inside each profile pages!
Just suscribing...

#2

lainwired - April 7, 2008 - 12:56

Have you aver checked out the advanced forum module? It is kinda hard to implement (i recommend using the Bio modules with it if you do). You can add all sorts of user information in the profile as well as user's buddies, user's recent posts.

#3

Rosamunda - April 8, 2008 - 15:26

Hi!
Yeah, I´m using that module, with Bio module too.
But it seems that you have to get installed the usernode module to get that block working....!

#4

ChristieLuv - May 26, 2008 - 17:44

Hi! Did you use the the Div's that are supposed to go to the top of that code because on this page it shows the code but it includes divs. You might also try it with different themes and see if its the theme thats interfering with it because I tried that code and worked after I switched around themes.

http://drupal.org/node/36501

#5

thet0olman - April 14, 2009 - 19:50

Is there a quick IF statement I can add to this so that it only shows up if the logged in user is the same as the users profile?

#6

thet0olman - April 14, 2009 - 20:03

By the way I figured out how to view the profiles buddy list instead of the logged in users buddy list

You have to replace

if ($buddies = buddylist_get_buddies($user->uid))

to

if ($buddies = buddylist_get_buddies($node->uid))

I hope that helps some people

#7

Inifnitee - July 19, 2009 - 10:20

replace
if ($buddies = buddylist_get_buddies($user->uid))

to
if ($buddies = buddylist_get_buddies($node->uid))

This did not work for me using Drupal 5.

 
 

Drupal is a registered trademark of Dries Buytaert.