Determines whether the user has access to a given field.
string $op: The operation to be performed. Possible values:
array $field: The full field structure array for the field on which the operation is to be performed. See field_info_field().
string $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.
TRUE if the operation is allowed; FALSE if the operation is denied.
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;
}