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

Chasen’s picture

I can think of multiple ways you could do this:

  1. If it's just one page, you could create a static block which contains the download link (rather than the body content of the page) and set the block permission to authenticated users - that way anonymous users can view the page but the download link only shows up for people who are logged in. To get your login functionality you could place the standard drupal login block on the same page and set its permission to anonymous only (so it doesn't bother people who are already logged in) so anons see a login block and auth users see the download link - you could tidy this up with a lightbox2 style pop up if you like, there's modules which can handle that.
  2. If it's for multiple pages and the download link will change, you can do the same as above but instead of manually creating a block, create a View which has a block (not a page) and that way the download link will be pulled in based off the page ID via a contextual filter - the rest is the same as above (re: permissions)
  3. You could also create a rules workflow where the download button shows for all users but you use the rules module to determine what action to take depending on whether the user is logged in or not.
  4. You could also just have the download link/button on the page and surround it with a <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
WorldFallz’s picture

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....