Hide the content while the current user has no access on
hook_query_alter() serves this purpose.

The exact query alter you want looks like this:

function modulename_query_node_access_alter(QueryAlterableInterface $query) {
  // Obtain node, if needed
  $node = $query-&gt;getMetaData('node');

  // Do some calculations

  // Add condition
  $query-&gt;condition( /* your custom conditions here */ );
}


More details on Query alteration documentation page.