Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By gorav.singal on
Hi
I have a content type, which shows a node having some fields. There is one file download field.
I want my users to login first before they download it. i.e. When users click on download link, my site should ask them to login first.
If a login pop up would come, that will be great.
Is there any module for this?
Thanks
Gorav Singal
Comments
Multiple options
I can think of multiple ways you could do this:
<div></div>
which you can target via CSS and have hidden (or jQuery/JS if you want to completely remove it) for anons and only visible for auth users. EDIT: to expand on this point, you'll need a theme which writes<body>
classes depending on whether the page is loaded for anon or auth users - Zen, as an example, does this by default. There's also other modules which will bolt this functionality into your existing theme_
In addition to the options above for listing the actual link, you'll also want to control permission to the files themselves. simply not showing the link doesn't actually protect the file. For that, you'll want to us core private file fields.
For more info, see http://getlevelten.com/blog/randall-knutson/requiring-registration-downl....