How do I programmatically set role based permissions on a field?
For example, I have field_my_field, for which I want the following permissions:
- Owner can view and edit
- Role X can view and edit
- Role Y can view only
Looking in the database, the role_permissions table looks like it's what contains the data, but I'm confused about the actual permissions, as they're very close to natural language. e.g. 'access site in maintenance mode' although field ones make more sense:
- Edit own field_my_field (owner can edit)
- View own field_my_field (owner can view)
- Edit field_my_field (can edit any)
I guess it's something along the lines of granting the permission to a RID, and identifying the module which interprets the permission.
Note: I'm trying to do this in another module with PHP - not in the UI. The Field Permissions module is great, but I need to do this in my code.