Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

This module adds a field type that allows you to control access to files. You can choose to make specific files downloadable only by users with the correct permissions, while still displaying the file to all users. This is useful for requiring registration or specific roles before allowing file downloads.

Protected file module provide a new field type which extends File field and permit to enable/disable for each file the possibility to prevent users to download the file, if they don't have the right permission, whereas the file is still visible on the page.

This module is useful if you want to prevent users to download file, but you want display the file regardless.

REQUIREMENTS

This module provide a new field type "Protected file" based on the File field type. File is provided by Drupal core.

This module requires that the private system file is available.

SIMILAR MODULES

Field permissions permit to set permissions on fields, and then can prevent users to access to file uploaded with a File field. But users without the permissions don't see then the file attached to an entity.

Protected file permit to display every files, but can prevent users to download them. This can be useful if you want that users have to register to be able to download some (specific) file(s).

INSTALLATION

Install as you would normally install a contributed Drupal module. See:
https://www.drupal.org/documentation/install/modules-themes/modules-8
for further information.

CONFIGURATION

  • Create a "Protected file" field on an entity
  • Configure the field settings as the standard File field (directory, extension, etc.)
  • Configure the field formatter : you can specify if the file is downloaded in a new tab, the redirect path for users without permissions, if the redirect path is open inside a modal or not, and the text used for the title link. If the redirect path is empty, and user has not the permission to download the protected file, then only the name of the file, without link, is displayed
  • Configure the permissions to allow Roles to download protected file
  • Create content and upload some files. For each file you can protect them by checking the protected checkbox

You can override the twig template protected-file-link.html.twig if you want
customize the feel and look of your protected files.

By default, the module provide and inject a markup based on a fontawesome class for protected
files (fa-lock icon). This markup is available in the {{ icon }} twig variable. You can easily
override it in the template or in a preprocess fonction.

This module was sponsored by Cerema.

Activity

Total releases
1
First release
Jun 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Release date
2.0.1 Stable Jun 25, 2025