Display comment box to the author of the node being referenced using panels I am creating a project that needs ONLY the author of a node being referenced AND the author of the referencing node to participate on comments on the referencing node, a sort of customer support Question/Answer system where ONLY the node author of the referencing node and the node author of the referenced node can participate in the comments section. I am implementing this with panels. 

So far i can show the comment block only to the referencing node author (Question author) using the following code which checks to see if node-author-id = logged-in-user id:

global $user;
if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
  // Get the nid
  $nid = arg(1);

  // Load the node if you need to
  $node = node_load($nid);
}

if($node-&gt;uid == $user-&gt;uid){
return TRUE;
} else {
return FALSE;
}


How do i also display this comment box to the author of the node being referenced?

Please note: The Question Content type and Answer Content type are two different content types

Thanks.

ps: I know about the Answers module as well as the Question/Answer modules. Somehow the best answer submodule included with the Answers7.x-4.0-rc2 module is able to let the author of the question flag an answer referencing his question as the best answer
Database query would help you.

function my_module_get_author_by_nid($node_nid) {
  $author = '';
  if (is_numeric($node_nid) &amp;&amp; $node_nid != 0) {
    $uid = db_select('node', 'n')
        -&gt;fields('n', array('uid'))
        -&gt;condition('nid', $node_nid, '=')
        -&gt;execute()
        -&gt;fetchField();
    return $uid;
  }
}


// And then a slight change in your code

    global $user;
    if (arg(0) == 'node' &amp;&amp; is_numeric(arg(1))) {
      // Get the nid
      $nid = arg(1);

      // Load the node if you need to
      $node = node_load($nid);
    }

     // Get Reference Node Nid
    $reference_nid = $node-&gt;your_reference_field_name[$node-&gt;language][0]['target_id'];
    // Get Author for reference Node
   $reference_author =  my_module_get_author_by_nid($reference_nid);
    if($node-&gt;uid == $user-&gt;uid || $user-&gt;uid == $reference_author){
      return TRUE;
    } else {
      return FALSE;
    }