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.

I'm creating a WordPress blog with some members-only page. In those members-only posts I have my own tutorial download links which i have uploaded for FREE. Problem is I want them to stop sharing the download link for the tutorials, instead of that I want to give them links which will only works once OR It will only work when it is accessed from mydomain.com ..

Can anyone help me? any idea would be much appriciated.

-Regards

share|improve this question
add comment

2 Answers

This sounds like something that eCommerce plugins should be able to handle.

My naive approach to this problem can be to generate a new URL each day by embedding the date in it and then checking with the date in the URL matches the current day before sending the file.

You will need a plugin that gives you the ability to use a shortcode to rmbed the URL, and checks the validity of it before sending the file.

// files assumed to reside at wp-content/uploads/daily

// use the shortcode like that
// [daylyurl file="file name" anchor="download it"]

add_shortcode('dailyurl','my77348_dailyurl');

function my77348_dailyurl($attr,$content='',$tags) {
  $url = get_option('siteurl').'?download='.$attr['file'].'&code='.md5(intval(time()/24*60*60));
  return "<a href="$url">$attr['anchor']</a>";
}

// handle the download itself

add_action('init','my77348_download');

function my77348_download() {
  if (isset($_GET['download'])) {
    if ($_GET['code'] == md5(intval(time()/24*60*60))) { // if it match it is legit
      $f = ABSPATH.'/wp-content/uploads/daily/'.$_GET['download'];
      // not sure if you can set mime types here or need to do all of this before init
      readfile($f); send the file itself
      exit();
    } else
      wp_die(404); // not legit
  }
}

This is not a production grade code as there are many sanity checks I omitted, and probably has a bug or more, but I think the concept should work as long as your members don't have a big incentive to try to hack it.

share|improve this answer
add comment

I believe that the Wordpress 'Download Manager' plugin might solve your problem!

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.