1. drupal
    1. 8
    2. 7
7 – 8 field_access($op, $field, $entity_type, $entity = NULL, $account = NULL)

Determine whether the user has access to a given field.


$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; e.g., '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; FALSE if the operation is denied.

Related topics

▾ 3 functions call field_access()

field_default_form in modules/field/
Create a separate form element for each field.
field_default_view in modules/field/
Builds a renderable array for one field on one entity instance.
file_file_download in modules/file/file.module
Implements hook_file_download().


modules/field/field.module, line 1009

function field_access($op, $field, $entity_type, $entity = NULL, $account = NULL) {
  global $user;

  if (!isset($account)) {
    $account = $user;

  foreach (module_implements('field_access') as $module) {
    $function = $module . '_field_access';
    $access = $function($op, $field, $entity_type, $entity, $account);
    if ($access === FALSE) {
      return FALSE;
  return TRUE;