Hide a field for that particular row based on value from custom table I have a custom module where in a user requests access to view a node. I have a view page which currently lists all nodes and has a button "Request Access" to it. When the user clicks on it, an entry for the same is captured in my custom table for that node id. Then the admin approves or rejects it. If it is approved i want the user to view "Approved" status for that node id and for others it should show "Request Access". The name of my custom table is access_node_custom. I tried using the below code (with some static data):

function access_node_custom_views_pre_render(&amp;$view) {
    if ($view-&gt;name !== 'access_node_custom'  || $view-&gt;current_display !== 'page_access_node_custom') {
        return;
    }

    $results = &amp;$view-&gt;result;
    foreach ($results as $key =&gt; $result) {
        if($result-&gt;nid == 656){
            $view-&gt;field['request_access']-&gt;options['exclude'] = TRUE; //Hide request access since this is already approved
        }
    }
}


The problem with this is that it hides for every row on that page. I am fairly new to drupal so I don't know how can i do this. Is it possible to use relationship? or query alter?

Thank you.
$view-&gt;field['request_access']-&gt;options['exclude'] = TRUE;


Exclude will always exclude the field for every single row. 

What you need to do is set it to null or empty ''

$result-&gt;field_request_access = null; // hide request


A possible downfall is that a user could guess, or have someone tell them the direct link, and still be able to see /node/656.

Thus; in addition, to what you're already doing, should also use hook_node_access

/*
 * Implements hook_node_access()
 */
function access_node_custom_node_access($node, $op, $account) {
  if($node-&gt;nid == 656 &amp;&amp; $op == 'view'){
    // some db_query here
    if ($something_is_true) {
      return NODE_ACCESS_ALLOW;
    }
    else {
      return NODE_ACCESS_DENY;
    }
  }
}


If the person does not have access, the above will automatically hide any "view" link in Views.