Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Can anyone help me out?
The included code:
function phptemplate_username($object) {
global $user;
/* Use the default theme_username for anonymous users, nodes by this user */
if ($user->uid == 0 || $object->uid == $user->uid || $object->uid == 0) {
return theme_username($object);
}
if (!user_access('maintain buddy list')) {
return theme_username($object);
}
/* an array, keyed on buddy uids */
$buddies = buddylist_get_buddies($user->uid);
/* Find out if this buddy is in the user's buddy list */
foreach ($buddies as $buddyuid => $buddystructure) {
if ($buddyuid == $object->uid) {
$output .= theme_username($object);
$output .= ' (';
$output .= theme('remove_from_buddylist_link', $object);
$output .= ')';
return $output;
}
}
/* The user is not in the buddylist, give a link to add */
$output .= theme_username($object);
$output .= ' (';
$output .= theme('add_to_buddylist_link', $object);
$output .= ')';
return $output;
}
Places 'add to buddylist' wherever it finds a username mentioned. Thats good, but I find it pretty annoying, is there a way to adapt this code so I can just put 'add to buddylist' in places of my choosing? In particular i am thinking of user list pages...
Thanks for any help :)
Comments
Comment #1
MichelleI just used the last comment here and it works:
http://drupal.org/node/35738
Michelle