1. commerce
    1. 7
7 commerce_product_file_download_access($field, $entity_type, $entity)

Implements hook_file_download_access().

This hook is grants access to files based on a user's access to the entity a file is attached to. For example, users with access to a product should be allowed to download files attached to that product. Here we do this on a per- field basis for files attached to products.


$field The field to which the file belongs.

$entity_type The type of $entity; for example, 'node' or 'user' or 'commerce_product'.

$entity The $entity to which $file is referenced.

Return value

TRUE if access should be allowed by this entity or FALSE if denied. Note that denial may be overridden by another entity controller, making this grant permissive rather than restrictive.


modules/product/commerce_product.module, line 185

function commerce_product_file_download_access($field, $entity_type, $entity) {
  if ($entity_type == 'commerce_product') {
    return field_access('view', $field, $entity_type, $entity);