Hi,

I try to use this snippet in block but no use. Please help me for creating link to Add "this" user as a friend.
Where this user= real name of user taken from profile.
I want to use this block at blog page and at user profile page. Any hint, please help.

Comments

marcor’s picture

Assigned: Unassigned » marcor
Priority: Critical » Minor
Status: Active » Fixed

This is rather a question of customization than module support and should usually be discussed in the forums.
If you reference a snippet, you should also mention which snippet you mean. ;)

You can get the users uid by

$uid = arg(1); // second part of the path user/1 on user profile page
Loading a user:
$account = user_load(array('uid' => $uid));
Get the name:
$name = $account->name;

Good luck!

web2’s picture

Sorry,

I want to create link for 'Add as a friend/buddy' in a block. I search entire forum for it but didn't get help. I found php snippet

<?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 buddylist',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 buddylist',array('@username'=>$user->name)), 'buddy/add/'. $user->uid);
        }
    }
}
?>

but no use.
I want more help with your code

<?php
$uid = arg(1); // second part of the path user/1 on user profile page
Loading a user:
$account = user_load(array('uid' => $uid));
Get the name:
$name = $account->name;
?>
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.