Is it possible to have a PHP input field, or any other method to allow field permissions based on, just about anything I suppose (just return a TRUE/FALSE), rather than just user roles?

In my case, I've got 'Jobs' that referenced (entity reference) to 'Vehicles'. 'Vehicles' are referenced to 'Sites'. I'd like to add a reference field in the user profile to choose what 'Site' a user is associated with (can be multiple).

Then depending on what sites are referenced in the user profile, the user can then edit specific fields in Jobs (that are referenced by vehicle >> site).

Hope this makes sense .. I may have overlooked something, first use of field_permissions.

Comments

jyee’s picture

PHP in an input field would require that custom PHP to be stored in the Database, which is generally regarded as a bad practice. Since your specific use case sounds fairly extensive (i.e. not a simple modification or extension to the default field_permissions), you should probably just write a custom module that uses hook_field_access() (which is the core function that field_permissions is using).

mariacha1’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

Yep, this is definitely beyond the scope of field permissions, although it might be possible with something like organic groups or some clever use of entity reference and conditional fields.