hook_download_authorize($user, $file_download)
ubercart/docs/hooks.php, line 311
Give clearance to a user to download a file.
By default the uc_file module can implement 3 restrictions on downloads: by number of IP addresses downloaded from, by number of downloads, and by a set expiration date. Developers wishing to add further restrictions can do so by implementing this hook. After the 3 aforementioned restrictions are checked, the uc_file module will check for implementations of this hook.
$user The drupal user object that has requested the download
$file_download The file download object as defined as a row from the uc_file_users table that grants the user the download
TRUE or FALSE depending on whether the user is to be permitted download of the requested files. When a implementation returns FALSE it should set an error message in Drupal using drupal_set_message() to inform customers of what is going on.
| Name | Description |
|---|---|
| Hooks | Allow modules to interact with the Drupal core. |
<?php
function hook_download_authorize($user, $file_download) {
if (!$user->status) {
drupal_set_message(t("This account has been banned and can't download files anymore. "),'error');
return FALSE;
}
else {
return TRUE;
}
}
?>