Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

This module allows you to control access to entity types and their bundles based on configurable conditions. This is useful for multi-site setups where different sites may need to access different entity types even when sharing a codebase.

A Drupal module that allows you to control access to entity types and their bundles based on configurable conditions.

Overview

Entity Type Access Conditions provides a flexible way to control access to entity types on your Drupal site. This module allows you to restrict operations like create, view, update, and delete for entity types and bundles based on various conditions. For example, you could restrict the creation of a specific content type to users with a certain role, or only on certain domains.

But why?

The benefit of this approach is for multi-sites, or shared codebase platforms, that share configuration across multiple sites but want some flexibility in what entity types are available. For example, if there are two sites sharing the same codebase, Site A and Site B, and only Site B should be able to create "Premium Article" content types, then using third party settings we are able to configure access to that content type based on a condition - this could be one provided by core, the contrib space, or something custom. This way both sites can still share the same configuration, as the third party settings are stored in config, but the conditions are evaluated per-site.

Requirements

- Drupal 10.x or 11.x
- PHP 8.1 or higher
- Conditions Helper

Installation

1. Download the module:
You can download the module using Composer:

composer require drupal/entity_type_access_conditions

2. Enable the module:
After downloading, enable the module using Drush or the Drupal admin interface:

drush en entity_type_access_conditions

Or, enable it through the admin interface at /admin/modules.

Configuration

The module offers a settings page to configure which conditions are available for use with restricting entity type access at: /admin/config/content/entity_type_access_conditions

Usage

1. Navigate to the configuration form for any supported entity type. For example, for a Node Type, go to Structure > Content types and edit a content type.
2. Look for the "Entity Type Access Conditions" section.
3. Add one or more conditions that determine when access should be granted.
4. Configure the condition parameters as needed.
5. Save the configuration.

Users who do not meet the configured conditions will not be able to perform restricted operations on that entity type or its bundles. Users with the 'bypass entity type access conditions' permission will always have access.

Extending the module

This module provides a plugin system to define which entity types should have access conditions. Developers can add support for new entity types by creating a YAML file in their own module named my_module.entity_type_access_conditions.yml.

In this file, you can define the entity type, the forms to alter, and which operations should be restricted.

For example, to add support for a custom entity type my_entity_type:

my_entity_type:
  label: 'My Entity Type'
  altered_forms:
    - my_entity_type_edit_form
    - my_entity_type_add_form
  restricted_operations:
    - view
    - update
    - delete

Additionally, developers can dynamically alter the list of forms that are altered using the provided hook:

/**
 * Implements hook_entity_type_access_conditions_form_ids_alter().
 */
function my_module_entity_type_access_conditions_form_ids_alter(array &$form_ids): void {
  // Add support for another entity type form.
  $form_ids[] = 'some_other_form_id';
}

Contributing

Contributions are welcome! If you would like to contribute to this module, please follow these steps:

1. Open an issue on the issue tracker
2. Create a Merge Request or add a patch
3. Mark your issue as Needs Review.

License

This module is licensed under the GPL-2.0+ license.

Maintainers

- Owen Bush

Depends on

Dependencies of the latest stable release

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Jun 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.1 Stable 10–11 Jun 9, 2025
1.0.0 Stable 10–11 Jun 5, 2025