Hi,

how can I can if there is an friendship request for a user-id?
Does there exist any function to do this?

thx

Comments

63reasons-AS’s picture

Please explain your point in detail.

thanks
63reasons-AS

alex.k’s picture

Title: Check friendship request » How to check for pending relationship requests
Assigned: Unassigned » alex.k

function user_relationships_load() does this. Pls read docs in user_relationships_api.api.inc. For example, to check if there are pending requests to a user, you can run

$count = user_relationships_load(array('requestee_id' => $user->uid, 'approved' => FALSE), array('count' => TRUE));
if ($count) {
 ...
dummas_324324_32’s picture

thanks.

dummas_324324_32’s picture

Status: Active » Closed (fixed)

closed

igorik’s picture

Status: Closed (fixed) » Active

Hi

as I wrote in http://drupal.org/node/387542

I am looking for an option to get number of ONLY pending requests I got from other users
Not both (my requests to other users and requests of others to me) as it is now (maybe I am wrong).

Now when I use

$count = user_relationships_load(array('requestee_id' => $user->uid, 'approved' => 0), array('count' => TRUE));

I got number of pending requests from other users together with my pending requests what I send to others.
This is not really intuitive. I would like to show only number of requests from others what want to be friends with me and notice user about this (if this number is different from zero).
maybe it could be new value for approved param, e.g. -1: 'approved'->-1

thanks for the help

mrf’s picture

Status: Active » Fixed

That snippet above should only return th count for pending relationships initiated by someone other than the current user with the current user as the object of the request.

If user_relationships_load is returning too many results in this case please open a new bug.

Status: Fixed » Closed (fixed)

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