Hello, I'm trying to enter a relationship id (rid) and the users in the relationship into node fields from a views list and I can't find it on the list. Would you please add it to views?

Thank you.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

7wonders’s picture

I am also curious if there is an existing way to get the rid into views?

rameshbabu.g’s picture

Bump

rameshbabu.g’s picture

Hi ,

you can use hook_views_pre_render(&$view)..For example

function modulename_views_pre_render(&$view) {
  if ($view->name == 'ur_view_machine_name') {
    foreach ($view->result as $res) {
       //UID of requstee user (Added <strong>uid</strong> field in view and took the relationship as requestee)
        $requestee = $res->users_user_relationships_1_uid;
       //UID of requster user (Added one more <strong>uid</strong> field in view and took the relationship as requester)
        $requester = $res->users_user_relationships_uid;
        //dsm($requestee);
        //dsm($requester);
        $row_rid = db_query("Select rid from {user_relationships} WHERE requestee_id = '$requestee' AND requester_id = '$requester' AND approved = '1' AND rtid = '1'");
<strong>//Get the rid</strong>
    }
  }
}
rfay’s picture

This is a super important request!

rfay’s picture

Version: 7.x-1.0-alpha4 » 7.x-1.x-dev
rfay’s picture

Status: Active » Needs review
FileSize
739 bytes

This should do the trick. Thanks to Tag1 Consulting for supporting this and contributing it back.

Fabianx’s picture

Status: Needs review » Reviewed & tested by the community

A clear yes!

Berdir’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed, thanks!

Status: Fixed » Closed (fixed)

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