function entity_access

7.x entity.module entity_access($op, $entity_type, $entity = NULL, $account = NULL)

Determines whether the given user can perform actions on an entity.

For create operations, the pattern is to create an entity and then check if the user has create access.

$node = entity_create('node', array('type' => 'page'));
$access = entity_access('create', 'node', $node, $account);


$op: The operation being performed. One of 'view', 'update', 'create' or 'delete'.

$entity_type: The entity type of the entity to check for.

$entity: Optionally an entity to check access for. If no entity is given, it will be determined whether access is allowed for all entities of the given type.

$account: The user to check for. Leave it to NULL to check for the global user.

Return value

boolean Whether access is allowed or not. If the entity type does not specify any access information, NULL is returned.

See also


14 calls to entity_access()
EntityAPICommentNodeAccessTestCase::testCommentNodeAccess in entity/entity.test
Tests comment access when node access is enabled.
EntityDrupalWrapper::entityAccess in entity/includes/
Checks whether the operation $op is allowed on the entity.
EntityMetadataIntegrationTestCase::testComments in entity/entity.test
Test properties of a comment.
EntityMetadataIntegrationTestCase::testCRUDfunctions in entity/entity.test
Runs some generic tests on each entity.
EntityMetadataNodeAccessTestCase::assertNodeMetadataAccess in entity/entity.test
Asserts node_access() correctly grants or denies access.

... See full list

3 string references to 'entity_access'
EntityBundleableUIController::hook_menu in entity/includes/
Provides definitions for implementing hook_menu().
EntityContentUIController::hook_menu in entity/includes/
Provides definitions for implementing hook_menu().
EntityDefaultUIController::hook_menu in entity/includes/
Provides definitions for implementing hook_menu().


entity/entity.module, line 655
Module file for the entity API.


function entity_access($op, $entity_type, $entity = NULL, $account = NULL) {
  if (($info = entity_get_info()) && isset($info[$entity_type]['access callback'])) {
    return $info[$entity_type]['access callback']($op, $entity, $account, $entity_type);