dynamic user access

  • Posts: 23
  • Thank you received: 0
  • Hikashop Business
3 months 1 week ago #347750

-- HikaShop version -- : 4.7.0
-- Joomla version -- : 4.latest
-- PHP version -- : 8.1

With your help, I managed to create a plugin that prints user information on each page of an e-book(s) via onBeforeDownloadFile.

In onBeforeDownloadFile, I take the user's email and other user info, add this information to each page of a pdf (using the Setas package), and create a new pdf file. The user can then download this new pdf file. This is called social digital rights management (social DRM). The idea is that when people see their name on each page of an E-book, they will think twice before uploading it to share with the rest of the world. From a coding point of view, it all works perfectly. Thanks for your help.

Now I want to add something extra. A university library may buy 10 of our E-books. If that happens, then I would like to implement the following.

1. A librarian purchases our package via hikashop.
2. The librarian gets an invoice, order number and an email with a download link.
3. The idea is that the librarian makes the order number available on their internal catalog, plus a link to our website. In specific to our 'Customer download space' menu item.
4. Now there are potentially hundreds of students from that library who want to download our e-books. But instead of the user info from the librarian, I want to add the email address of the student to each page of each pdf.

My question is now as follows. Once a student logs into the 'Customer download space' (using the login info from the librarian)....how can I now collect information from the student and pass that on into onBeforeDownloadFile? To be more specific, before they click on the download button, I need to grab their email address via a pop-up message and pass this into onBeforeDownloadFile so that I can grab it there, and create a new pdf again.

Where would I do this? Or is there any other way of doing this? Or should I go the Joomla usergroup route?

So..in short....the purchased product is associated to a specific client and I need to give hundreds of other people access to it. But I want to extract information from the original purchaser and from hundreds of students to an existing pdf.

Kind regards,


Please Log in or Create an account to join the conversation.

  • Posts: 78298
  • Thank you received: 12367
3 months 1 week ago #347755


In that case, I would recommend you add a controller and a view in the plugin where you have your onBeforeDownloadFile.
You can do that basing yourself on the plugin in plugins/hikashop/email_history/
This plugin implements the event onHikashopPluginController to add its own controller to HikaShop and a file email_history_ctrl.php to handle the tasks. Then, in its views folder, it has views to display stuff. This plugin is the one responsible for the Customers>Emails history menu in the backend of HikaShop. It does everything in there without any code in HikaShop specific to that function. So it's a good starting point to add extra stuff to HikaShop.
You would have one task in your controller which would display a view. That view would have a form where the user could enter his information and submit. The action of the form would point at the download URL of the order with extra parameters in the URL so that you could get them in the onBeforeDownloadFile event to generate the PDF accordingly.

Please Log in or Create an account to join the conversation.

Time to create page: 0.053 seconds
Powered by Kunena Forum