in my e-learning website i sell my tutorials. my files are there in private folder and after paying for each set of files, users have access to download that specific set of files... to implement that; so far i used this module: "Private files download permission" = Allows by-user and by-role downloads from private file system directories.
so for each set of files i have to created a separate role!
my problem: now i have so many roles and it is getting more difficult to organize them!

now i am thinking of other solutions such as using taxonomy!
i can create a form to upload a file to private folder and assign a taxonomy to it!
1- any user who pay for it, can get that taxonomy and can download it but i don't have a clear idea how to assign this taxonomy to a user after paying?
2- how can i let him download from private folder if that user has the taxonomy? i can do it all by PHP coding and hooks but is there any module which can do half of the job at least? or if there is no module to help me...can i use Rules to check if a user has a certain taxonomy or not?

| improve this question | | | | |
  • You can assign taxonomy to a node and but not a file. Are you uploading the file as a field of a node of any particular content type. – Nabil Mar 4 '14 at 12:04
  • it looks a simple way but i didn't get the process clearly! - is there a way to assign taxonomy to users? - will the links be there inside the nodes? so can them share the links with others? i want only the user who bought that set to be able to downoad – PersianMan Mar 4 '14 at 13:51

One easy way of doing this, is to use hook_preprocess_node(), and in that function, check for that specific term. And depending on that term, you can actually unset() that file download field in the node, and insert "Please sign up", or something, message in it's place.

| improve this answer | | | | |
  • i didnt find this function in drupal api – PersianMan Mar 4 '14 at 16:44
  • It's techically, hook_prerocess_hook(). But you use it like hook_preprocess_page(&$page), or hook_prerocess_node(&$node), etc. I mean, themename_preprocess_page, or modulename_preprocess_page, etc. – Alexei Rayu Mar 4 '14 at 18:52
  • sorry to ask this question here: can i use hooks inside a node while the editor is php editor? – PersianMan Mar 5 '14 at 18:13
  • Some hooks. But you need to understand that this is a bad practice, having php in database. – Alexei Rayu Mar 5 '14 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.