hook_file_download_access_alter
function hook_file_download_access_alter
hook_file_download_access_alter(&$grants, $file_item, $entity_type, $entity)
Alter the access rules applied to a file download.
Entities that implement file management set the access rules for their individual files. Module may use this hook to create custom access rules for file downloads.
Parameters
$grants: An array of grants gathered by hook_file_download_access(). The array is keyed by the module that defines the entity type's access control; the values are Boolean grant responses for each module.
array $file_item: The array of information about the file to alter access for.
$entity_type: The type of $entity; for example, 'node' or 'user'.
$entity: The $entity to which $file is referenced.
See also
File
- modules/file/file.api.php, line 55
- Hooks for file module.
Code
function hook_file_download_access_alter(&$grants, $file_item, $entity_type, $entity) { // For our example module, we always enforce the rules set by node module. if (isset($grants['node'])) { $grants = array('node' => $grants['node']); } }
© 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!file!file.api.php/function/hook_file_download_access_alter/7.x