function opigno_forum_node_access in Opigno forum 8
Same name and namespace in other branches
- 3.x opigno_forum.module \opigno_forum_node_access()
Implements hook_node_access().
File
- ./opigno_forum.module, line 180 
- Contains opigno_forum.module.
Code
function opigno_forum_node_access(NodeInterface $node, $op, AccountInterface $account) {
  if ($node
    ->bundle() === 'forum' && $node
    ->hasField('taxonomy_forums')) {
    // Check current user access to the forum topic node.
    $tid = $node
      ->get('taxonomy_forums')
      ->getValue()[0]['target_id'];
    return AccessResult::forbiddenIf(!_opigno_forum_access($tid, $account));
  }
  return AccessResult::neutral();
}