Question

I have a Drupal 7 site that has downloadable resources (PDF files) in blocks that need to be visible to all visitors, but only available for logged in visitors to download. How can I accomplish this?

Any advice is great appreciated.

Thanks!

Was it helpful?

Solution

Consider using Private files for your file field and let Drupal handle all this.

Here is how to work with files in Drupal 7. This should put you on the right track.

Hope this helps.

OTHER TIPS

   <?php
   global $user;
   if($user->uid != "") {
           $path = "/sites/default/files/example.pdf";
   } else {
           $path ="#";
   }
   ?>
   <p><a href="<?php echo $path ?>"><span style="font-size: small;"><span style="font-family: Arial;"><span style="color: rgb(255, 153, 0);">Example.pdf</span></span></span></a></p>

Hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top