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

1 function implements hook_field_access()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_test_field_access in modules/field/tests/field_test.field.inc
Implements hook_field_access().

File

modules/field/field.api.php, line 2777
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;
}