/** * Implements hook_node_grants(). */ function {{ machine_name }}_node_grants(\Drupal\Core\Session\AccountInterface $account, $op) { if ($account->hasPermission('access private content')) { $grants['example'] = [1]; } if ($account->id()) { $grants['example_author'] = [$account->id()]; } return $grants; }