I need to have a field in user profile named Employee ID, this field should only be set by admin (Read and write), read-only to user, and hidden from all other users. Thank you.
2 Answers
You can use the field_permissions module to set up permissions for fields by user role and then limit access to admin. If you want to limit to one person then set up a separate role and give that role only to one person.
-
Well, tried that, not working. I did custom permission, "View own" checked for all users, edit all for just the admin this ended me up with hiding the field from anyone except admin. Commented Nov 20, 2019 at 1:31
-
Did you check settings in display tab for the entity? Do fields have settings there associated with this module? Commented Nov 20, 2019 at 1:43
-
Yes, I checked "manage display" but there is no settings button in there Commented Nov 21, 2019 at 11:51
-
I have added a bug report on Drupal.org around this - drupal.org/project/field_permissions/issues/3096324 - Would be great if you can respond there with any additional information. It is always good to let module maintainers know of issues in the module via Drupal.org Commented Nov 23, 2019 at 1:49
Well, finally found the answer, use this module: field_readonly The best way of having it to work is to install field_permissions module (or any field permission module or code) first, set all the permissions (this will hide the field completely but do not worry go ahead) and then just install field read-only, the module gets it from there and make it visible and read only :)