So this other day I was trying to get a new functionality to work for a client’s website. Unique download URLs for each time a new visitor clicks on a specific button in WordPress
How would the whole thing work:
Let’s say I have a button on the left widget area of my website that says “Download Ebook Now”.
-I need each visitor to be redirected to a unique URL ( that will expire after x amount of time)
-On the separate page , the download link will be provided as normal
Do you happen to know if there is a plugin or script out there that could handle such a task or another solution to go about implementing this?
Thanks!
If you want to use Amazon S3 to host the downloadable files, the ability to generate unique expiring URLs is a feature of the S3 API.
I would personally use Amazon S3 as suggested which has support for unique expiring URL’s. Sites like Net Tuts use this approach for their paying members wanting to download premium files. If you don’t want to go down that route, it’s rather easy to implement something simple.
You basically want to generate a unique token by adding a row to a table with an expiration time. When a user accesses the URL with said token, you pull out the date and then compare it to the current date, if it has been 24 hours since created for example. than either flag or delete the code.
Getting the URL’s to work with WordPress however will require you look into the WP_Rewrite class to add in custom rewrite URL’s for this functionality. As for the unique codes, I’d just MD5 the current date and time to create unique codes and maybe append a random number at the end using rand.
You could use page that has the PDF embedded in it which would interact with wordpress’s user system and only load if the user is logged in and authorized.