How to prevent a View from rendering via a hook?
Wanted to do similar but just $view-&gt;executed = TRUE; made the query in the view still run. Looking at view::build(), I understood you need the following code, to prevent anything running further in the view (displays and query).

$view-&gt;executed = TRUE;
$view-&gt;built = TRUE;


To make it clearer, the code you should use is the following one.

function ding_eresource_views_pre_view(&amp;$view, &amp;$display_id, &amp;$args) {
  if ($view-&gt;name == 'eresource_list' &amp;&amp; $display_id == 'attachment_1') {
    // Prevent rendering if parent view has some option set.
    if (!empty($view-&gt;old_view[1]-&gt;barr)) {
      // This does not work. How can it be done?
      $view-&gt;executed = TRUE;
      $view-&gt;built = TRUE;
    }
  }
}