Field Permissions: How do I Grant Access to Individual Drupal Fields?

Field permissions module is one of those modules that truly unleashes Drupal's power. It isn't needed on every site, but if you want or need more fine control permissions of individual fields or entities, this is the module for you.

Some use cases for Field Permissions are:

  • Needing to hide a field for anonymous users on the front-end.
    • Add new fields to content for testing purposes before released to the public.
    • Provide extra information to registered users.
  • Restricted edit access to certain user roles for individual fields.
  • Allow anonymous users to create values for fields.

The great thing about the module is if you don't set special permissions for a field then the default settings are used which are the ones set at the content type level. Let's take a look at the module in a bit more detail.

Info

Field Permission
https://www.drupal.org/project/field_permissions

Actively maintained No, Minimally maintained
Maintainers monitor issues, but fast responses are not guaranteed.
About 80,000 sites report using it at the time of writing.
This module has been around for a long time and I would say it is feature complete and very stable.

Requires No extra requirements.
Libraries No library.

Install either using the UI or composer.

Basics

Once installed you need to navigate to the manage fields pages for the content type of the field you want to set special permissions for. Click on the edit field button and then find the field settings section of the edit form.

If you have many roles, you can see all the role's permission. Just remember once explicitly set, you must enable every permission for each role, otherwise, the users from the different roles will not be able to see it even if they have edit access to the content type.

If you run a smaller site and most users have the administrator roles then you can use the Private: Only author and administrators can edit and view, which is a nice feature.

However, if you have more fine-grained roles you will need to use the Custom permissions: Define custom permissions for this field settings and check what roles have what permissions as illustrated below.

Advanced Settings and Reports

You can access these from the module extend page directly or use the toolbar and default Drupal navigation.

Module Permissions

If you have more than one type of administrator then you may need to give another role access to administering the module's functionality.

Manage >  Administration  > People > Permissions
/admin/people/permissions/module/field_permissions

Field Permissions Report

The module adds a report page to the field list section, this is helpful to see an overview of the field permission settings.

Manage >  Administration  > Reports > Field list > Field permissions
/admin/reports/fields/permissions

That's it for the Field Permission module. It is the sort of module that allows you to make better user experiences, be it the experience of an anonymous user or that of a member or administrator of your site or application. I personally link being able to add a field that is only shown to logged-in users but I have also built content types that have allowed anonymous users to add information to a content type. 

Thanks for reading and be sure to sign up for the newsletter if you are interested in design and technology. I write about front-end development. Until next time, seize the day!

 

 

Tags