Hello.

I followed the API description in the handbook (http://drupal.org/node/203396) but found that this has changed for D6.

e.g.

In D5, you call:
user_relationships_load($param = array(), $count = FALSE, $sort = 'rid', $order = NULL, $limit = NULL, $include_user_info = FALSE)

In D6, you call:
user_relationships_load($params, $options, FALSE); (where both $params and $options are arrays)

I am trying to call this function within a module function like so:

  $user_id = $GLOBALS['user']->name;
  $params = array("user" => $user_id, 'rtid' => 1);
  $options = array("count" => FALSE, 'sort' => 'rtid', 'order' => 'rid DESC', 'limit' => '10', 'include_user_info' => TRUE);
  $friends = user_relationships_load($params, $options, TRUE);
  $page_content = '';
  $page_content .= "<pre>";
  $page_content .= print_r($friends, true);
  $page_content .= "</pre>"; 
  return $page_content;

But the array is empty. Can someone point out what I'm doing wrong?

Thanks!

Comments

allanh’s picture

WOW. I'm so sorry about all the submissions on this. It kept giving me a white screen of death after submitting, and then a 'page not found' a couple of times. I didn't think it would create so many entries. Please forgive me!!

steve22’s picture

Why don't you delete the rest of the posts?

allanh’s picture

I would be happy to clean up after myself, but unless I'm completely blind, I don't have permissions to do so.

allanh’s picture

Priority: Normal » Minor
Status: Active » Closed (fixed)

Never mind. It was the simple fact that I was using

$user_id = $GLOBALS['user']->name;

When I should have been using $uid (the users user *number*, not the string).

I'm sorry again about the repeated posts. Again, I would delete them, but I can't.

alex.k’s picture

Priority: Minor » Normal
Status: Closed (fixed) » Active

@allanh no worries, please just link from other issues to this one and close them.

You need something like

global $user;
$user_id = $user->uid;
$params = array("requester_id" => $user_id, 'rtid' => 1);
$options = array('sort' => 'rtid', 'order' => 'rid DESC', 'limit' => '10', 'include_user_info' => TRUE);
$friends = user_relationships_load($params, $options);
.....
alex.k’s picture

Status: Active » Fixed

Oops, did not see you got it sorted.

allanh’s picture

Thank you very much Alex.

Status: Fixed » Closed (fixed)

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