Skip to content

Determining entity access

Available since: 1.0.0

Provided tokens

Token Description
[event] The event.
[event:entity_bundle] The bundle of the entity.
[event:entity_id] The entity ID, only available if the entity is not new.
[event:entity_type] The entity type.
[event:operation] The operation with which the entity should be accessed, e.g. "view", "update", etc.
[event:uid] The ID of the user account of the event.
[event] The event.
[event:machine_name] The machine name of the ECA event.
[session_user] The user account that dispatched the event, regardless if ECA is processing models under a different account. This is only available if ECA is configured to always run under a specific account.
[account] The user account of the event.
[entity] The entity of the event.
[ENTITY_TYPE] The entity of the event under the name of its entity type.

Fires when Drupal checks whether a user can perform an operation on an existing entity. This wraps Drupal's hook_entity_access().

Use the Set access result action to grant or deny access.

The account token is the checked account

The [account] token is the account being checked for access, not necessarily the currently logged-in user. When code checks access for a different user (e.g., $entity->access('view', $other_user)), the [account] token reflects that other user.

Performance consideration

Access results from ECA are not cached (maxAge=0). Use specific filters (entity type, bundle, operation) to minimize the performance impact.

Fields

For any successor of this event, the account that asks for access is available under the <strong>[account]</strong> token. Example: <strong>[account:uid]</strong> provides the user ID of the account.

Furthermore, following data of the event is available:<ul><li><strong>[event:operation]</strong> holds the requested operation, such as "view".</li></ul>

Restrict by entity type ID

Example: node, taxonomy_term, user

Restricts to the specified entity type (e.g., node, taxonomy_term). Comma-separated for multiple values.

Restrict by entity bundle

Example: article, tags

Restricts to the specified bundle (e.g., article, tags). Comma-separated for multiple values.

Restrict by operation

Example: view, update, delete

Restricts to the specified operation (e.g., view, update, delete). Comma-separated for multiple values.