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.
hi guys like the title say.
how i can check this?
in buddylist i used the following to check whether someony is my friend or not:
if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list'))
{ $mybuddy = 1 ; } else { $mybuddy = 0 ; }
please someone help me
regards
Lausch
PS: also possible to check in witch relationship group my user is?
Comments
Comment #1
sprsquish CreditAttribution: sprsquish commentedSure. It's pretty easy actually.
Comment #2
Lausch CreditAttribution: Lausch commentedhi, thanks for your help,
$mybuddy is empty? what do i wrong?
i need simply a check whether the profile i view is from my buddy or not...
the last
worked for me...
i need it for example to show the messages like
this is your friend
or
this is not your friend
regards
Lausch
Comment #3
sprsquish CreditAttribution: sprsquish commentedWell, I'm not sure why it's not working. If you create two users (1 and 2) and set them as follows and create a relationship between them that code should work. To simplify it and only set $mybuddy to 1 if the person is a buddy or 0 if not you could do the following:
That will set
$mybuddy
to1
if there is any relationship between the two users and0
if not. It's a drop in replacement for the code you're showing me.Comment #4
Lausch CreditAttribution: Lausch commentedok hum,
i tryd the following now:
$mybuddy = !!($relationships = user_relationships_load(array('between' => array($user->uid, $GLOBALS['user']->uid))));
now it returns 1 if it is my buddy or NOTHING if it isnt my buddy.
regards
Lausch
Comment #5
sprsquish CreditAttribution: sprsquish commentedOkay, I think I see the problem.
What are you trying to use to display the value of
$mybuddy
? It looks like you're usingprint($mybuddy)
If that's the case you'll get exactly the results you're seeing.Try using
var_dump($mybuddy)
You should see it dump out "bool(true)" if the person is your buddy and "bool(false)" if not. This is correct behaviour.If you'd still like to set
$mybuddy
to 1 if it is a buddy or 0 if it's not you can use the following:If you then use
print($mybuddy)
you'll see 1 if their a buddy and 0 if not.Comment #6
Lausch CreditAttribution: Lausch commentedok many many thanks!
now it works for me :-)
best regards
Lausch
Comment #7
Lausch CreditAttribution: Lausch commented