Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

4 Answers 4

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

The plugin I use for this is Amazon S3 URL Generator it's kinda old but I've not had issues with it. Still use it on current sites.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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