You are here

function node_example_access in Examples for Developers 6

Implementation of hook_access().

Node modules may implement node_access() to determine the operations users may perform on nodes. This example uses a very common access pattern.

Related topics

File

node_example/node_example.module, line 105
This is an example outlining how a module can be used to define a new node type.

Code

function node_example_access($op, $node, $account) {
  if ($op == 'create') {
    return user_access('create example content', $account);
  }
  if ($op == 'update') {
    if (user_access('edit any example content', $account) || user_access('edit own example content', $account) && $account->uid == $node->uid) {
      return TRUE;
    }
  }
  if ($op == 'delete') {
    if (user_access('delete any example content', $account) || user_access('delete own example content', $account) && $account->uid == $node->uid) {
      return TRUE;
    }
  }
}