Skip navigation


7 uc_file.api.php hook_uc_download_authorize($user, $file_download)

Gives 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

Return value

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.

Related topics

1 invocation of hook_uc_download_authorize()


ubercart/uc_file/uc_file.api.php, line 34
Hooks provided by the File Downloads module.


function hook_uc_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;