hook_access

  1. drupal
    1. drupal6
    2. drupal7 node.api.php
Versionen
drupal6 – drupal7 hook_access($op, $node, $account)

Define access restrictions.

This hook allows node modules to limit access to the node types they define.

Übergabeparameter

$op The operation to be performed. Possible values:

  • "create"
  • "delete"
  • "update"
  • "view"

$node The node on which the operation is to be performed, or, if it does not yet exist, the type of node to be created.

$account A user object representing the user for whom the operation is to be performed.

Rückgabewert

TRUE if the operation is to be allowed; FALSE if the operation is to be denied; NULL to not override the settings in the node_access table, or access control modules.

The administrative account (user ID #1) always passes any access check, so this hook is not called in that case. If this hook is not defined for a node type, all access checks will fail, so only the administrator will be able to see content of that type. However, users with the "administer nodes" permission may always view and edit content through the administrative interface.

See also

http://api.drupal.org/api/group/node_access/6

For a detailed usage example, see node_example.module.

Verwandte Themen

Code

developer-docs/hooks/node.php, line 162

<?php
function hook_access($op, $node, $account) {
  if ($op == 'create') {
    return user_access('create stories', $account);
  }

  if ($op == 'update' || $op == 'delete') {
    if (user_access('edit own stories', $account) && ($account->uid == $node->uid)) {
      return TRUE;
    }
  }
}
?>

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen