You are here

function opigno_forum_node_access in Opigno forum 3.x

Same name and namespace in other branches
  1. 8 opigno_forum.module \opigno_forum_node_access()

Implements hook_node_access().

File

./opigno_forum.module, line 185
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();
}