function hook_field_access
hook_field_access($op, $field, $entity_type, $entity, $account)
Determine whether the user has access to a given field.
This hook is invoked from field_access() to let modules block access to operations on fields. If no module returns FALSE, the operation is allowed.
Parameters
$op: The operation to be performed. Possible values: 'edit', 'view'.
$field: The field on which the operation is to be performed.
$entity_type: The type of $entity; for example, 'node' or 'user'.
$entity: (optional) The entity for the operation.
$account: (optional) The account to check; if not given use currently logged in user.
Return value
TRUE if the operation is allowed, and FALSE if the operation is denied.
Related topics
File
- modules/field/field.api.php, line 2751
- Hooks provided by the Field module.
Code
function hook_field_access($op, $field, $entity_type, $entity, $account) { if ($field['field_name'] == 'field_of_interest' && $op == 'edit') { return user_access('edit field of interest', $account); } return TRUE; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!field!field.api.php/function/hook_field_access/7.x