field_access
This module provides access control functionality for entity fields. It allows
developers to easily configure access to view and edit fields based on user
roles.
Features
Developers can create permission maps per entity type and bundle in the form of PHP arrays that allow them to define whether a user should be granted access to view or edit a field value based on the user's roles and permissions. There is currently no UI for site builders or site administrators.
Post-Installation
Usage instructions can be found in the README file.
Additional Requirements
Requires PHP 8.0+, Drupal 9.0+.
Similar projects
Field Permissions is a module that provides similar functionality.
The Configurable Field Access module was created to improve on what I see as shortcomings in the Field Permissions module. It provides:
- Better developer experience; UI for site builders might come later.
- Easy overview of all permissions of an entity type in a single PHP file. Having to jump around different forms in the UI or different configuration files make it really difficult to review all permissions for all fields and that makes the process error-prone.
- Support for both base and bundle fields.
- Per bundle permissions for fields with the same machine name.
- Default permissions for all bundles with the ability to override them for specific bundles only.
- Different permissions when setting the field value on a new entity compared to when updating the value on an existing entity. This can be helpful if you want to allow, for example, setting the subject of a comment when creating it but disallow updating it once saved while allowing updates in the comment's body.
- Support for granting access based on roles and/or permissions.
- Support for matching roles using regular expressions.
- Support for matching fields using regular expressions.
- Zero spam in your user role and field storage configuration files.
Supporting this Module
Create issues in the Drupal.org queue, submit MRs. If you are interested in sponsoring this module to add more features, contact the module maintainers.