Hello,

I am new in Drupal and PHP and I have a question.

with this code (when he is placed in the visibility settings) blocks are only shown to people hwo have a relationship to a user.

global $user;
$profile_uid = arg(1);
if (in_array('administrator', $user->roles))
  {
return TRUE;
} else {
  return user_relationships_load(array('between' => array($user->uid, $profile_uid), 'approved' => 1), array('count' => TRUE));
}

But what have I to change when I want to show the Block to a specific relation (for example "buddy")

I hope anyone can help me?

Best regards
Frank

Comments

mrf’s picture

Status: Active » Fixed
<?php
  global $user;
  $profile_uid = arg(1);
  return user_relationships_load(array('between' => array($user->uid, $profile_uid), 'approved' => 1, 'rtid' => array(2)), array('count' => TRUE));
?>

That should do it for you the new important piece is rtid => array, you'll need to make sure you include the id of your buddy relationship there. Easy way to find that is going into the relationships admin and editing the relationship, the ID will be in the url path.

fraweg’s picture

Thanks a lot!!!

Best regards
Frank

Status: Fixed » Closed (fixed)

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