Wednesday, 18 August 2010 15:48

How to Force Users to Login before Downloading K2 Item Attachments

Written by 
How to Force Users to Login before Downloading K2 Item Attachments

One of the great uses that K2 (Joomla Component) claims that their system can do is act as a download manager.  However, it does not have the ability to restrict downloads to only logged-in users.  I needed a system where we could display the K2 item, with a preview and description, but not actually let them download the attachments.  This was not achievable using just the included K2 parameters / settings, so I made this hack:

LOOK IN THIS FILE:
/com_k2/templates/templatename/item.php (line 364)

Download the attachment (Item.php K2 Template Modification Code) for the actual changes you need to make.

(note: stock, this will appear in your K2 component folder (/components/com_k2).  You SHOULD be creating a template override (/templates/yourtemplate/html/) using the technique described here.

Read 11338 times Last modified on Wednesday, 18 August 2010 16:06

2 comments

  • Comment Link k_s_c Friday, 20 August 2010 08:41 posted by k_s_c

    Thanks for the code, looking forward to testing it...

    I hope you also appreciate the irony of offering a script to prevent downloads of attachments without registration, as an attachment that can be downloaded without registration ;-)

  • Comment Link Kipp Thursday, 19 August 2010 10:47 posted by Kipp

    Going to try it out. If it works I will holla back.

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.