wpsharks / s2member

s2Member® Framework (membership management for WordPress®).
64 stars 36 forks source link

Advanced Download Restrictions giving (503) Invalid Key error #1146

Open rnwhalley opened 6 years ago

rnwhalley commented 6 years ago

EXPLANATION OF THE ISSUE

My site is running S2 Member (Version 170722 + s2Member Pro v170722) and provides members with access to download files held on Amazon Web Services S3. This works fine but I also need to give non-members access to download some of the files and have been trying to use the S2 "Advanced Download Restrictions" for this.

STEPS TO REPRODUCE THE ISSUE

I have attempted to use the following syntax with ezPHP:

https://lenscraft.co.uk/?s2member_file_download=example-file.zip&s2member_file_download_key=<?php echo s2member_file_download_key("example-file.zip"); ?>

and also as a shortcode without using PHP:

https://lenscraft.co.uk/?s2member_file_download=example-file.zip&s2member_file_download_key=[s2Key file_download="example-file.zip" /]

In both instances, I received the error message

503 (Invalid Key): Sorry, your access to this file has expired. Please contact Support for assistance.

I have however been able to create a working link using the shortcode:

[s2File download="example-file.zip" download_key="true" /]

When I examine the structure of the link created by the working shortcode, it differs from that created by the other. What you have for the working link is:

"domain" + "download key" + "S2 download location"

But for the codes that create the invalid key error the structure is:

"domain" + "S2 download location" + "download key"

It is possible to create a link that works using the other shortcode if you change the structure of the link. For example:

https://lenscraft.co.uk/?&s2member_file_download_key=[s2Key file_download="example-file.zip" /]&s2member_file_download=example-file.zip

I hope this helps.