Request a hook for downloads without hash
-
How do you feel about requests for hooks? I think I could use one to try to gracefully handle old download links from our previous plugin that did not require hashes.
We have sent out a number of download links in things like email newsletters over the years. Some of them were intended to be able to be reused for future reference. I would like to find a better way to treat our visitors who might click those links than serve them a wp_die() message for clicking a link we ourselves sent them.
If it is no trouble, I would like to get some kind of hook where I could handle those old cases. I have done some experimenting, and here is an example hook would allows some flexibility:
$hash_key = apply_filters('simple_download_counter_download_hash', $hash_key, $id, $hash);
That would go right after
$hash_key
is defined ininc/functions-core.php
, line 282. Then we could do things like these (I have tested both options):- Allow old links sent before we used hashes to still work by returning the expected hash if the
$id
is in the range of the known old downloads and akey
url parameter is not set. - Send the user to the 404 page where the option to search is offered.
If a person wanted to disable requiring hashes entirely, it could also work for that.
Totally unrelated: I just realized you are the person responsible for the 7G Firewall rules that I have been running on our sites for the last few years. Now I am doubly grateful, and you have my respect.
- Allow old links sent before we used hashes to still work by returning the expected hash if the
- The topic ‘Request a hook for downloads without hash’ is closed to new replies.