hey guys!!
i need a simple snippet that will result in a link that i will be putting in user_profile.tpl.

if i visit a users profile i want there to be a link that says add as friend if user is not a friend and remove as friend if the user is a friend.

i searched http://drupal.org/node/35738 and http://drupal.org/node/36501 and neither of them work or is what i need.
if someone could plz heap me thanks!!

Comments

esllou’s picture

this any good?

<?php
if ($GLOBALS['user']->uid != $user->uid) {
    if (@in_array($user->uid, array_keys(buddylist_get_buddies($viewing_user->uid))) && user_access('maintain buddy list')) {
        print l(t('Remove @username from your contact list',array('@username'=>$user->name)), 'buddy/delete/'. $user->uid);
    }
    else {
        if ($user->uid != $viewing_user->uid && user_access('maintain buddy list')) {
            print l(t('Add @username to your contact list',array('@username'=>$user->name)), 'buddy/add/'. $user->uid);
        }
    }
}
?>
apina’s picture

no thats one of the snippets i tried that did not work

esllou’s picture

well I'm using 5.2 and that snippet works perfectly in my user-profile.tpl.php template.

esllou’s picture

double post.