Assign a download a multiple download count

Hello, I am wondering if I can seek some support on the following please.

I use s2Member to sell access to downloads of PDF files, it does the job. However, I wish to sell downloads of multiple PDFs in a ZIP folder, which I can do no problem. However, I would like to be able to assign a download count to the ZIP above the standard 1 download. For example, if the ZIP contains 10 PDF files, I wish it to count as 10 downloads not 1.

I have had a couple of developers look at this and this is there response:

We found the area inside WordPress where S2 stores the counter of downloads.What we haven’t been able to find is where those values are assigned. It seems the default way S2 works is to give each file download a count of 1, which is a normal behaviour as you’d expect. What your objective to me was to see if we can assign a different value to different types of file downloads, specifically a Zip file with multiple files inside it. Since there’s no way inside the WP admin area to assign that value to a file, my thought was to try to assign that counter value programmatically.

The place I tried was inside WP’s functions.php file, where I was hoping to be able to override that file value when the page with the file download was built. It’s pretty easy to do that, but I couldn’t find the API elements inside S2 to make that change. When I tried to force it, all of WP would crash and I’d get the “Something bad happened” screen.

After a few of those, I removed my code from functions.php.

Basically, the question for S2 is this: can you change the counter value of a file. If so, is it best to do it programmatically as a function? If we know the answer to that, we can adapt our code to read the file name, where my plan is to place a counter value. For example, we would have a file called Math-year1-group-file5.zip. That file would get downloaded as intended, but our function would fire on download and read the filename for the “file” string and capture the integer right after it (and before the dot.) That would be our value. It also means people making these files wouldn’t have to mess with anything in the WordPress backend, they could just name the file a certain way.

This method of reading the file name requires a step on file creation, but it will end up being much faster than grabbing the file from WordPress OR S3, unpacking it, counting the files, etc. With the volume of downloads you do, that’s a ton of bandwidth and CPU cycles open a zip file and then delete it right away.

Please can anyone advise on this?

Thanks!

Any ideas anyone?

Hi Ed.

I’m not sure I understood exactly what you mean to do. You wan to have a protected zip file with several pdf files, and count the downloads of those with s2? I probably didn’t get it right…

In any case, it seems you have a competent guy working on your customization. If you could describe the above with some examples, that may help me understand.

s2’s integration with S3 generates a download link for S3, s2 doesn’t serve the files. When the files are in the /wp-content/plugins/s2member-files/ directory, s2member serves the file. Not sure if that helps.

Any way, if you want to give me some examples to clarify what you’re attempting, I’ll be happen to comment some more, maybe something that helps you.

Also, why do you want to do it that way? Would there be another acceptable way?

:slight_smile:

Hi Cristián,

Thanks for coming back to me.

So we are an educational resource provider, we sell access to digital downloads. Our resources are usually PDF and PowerPoints, which are mapped to the English Curriculum. They follow a framework for example Block 1 may contain 10 steps - each step could be a download. Currently our customers need to download each step 1 by 1, but we would like to be able to offer an option to download the whole block in one .ZIP file. However, this would equal one download off the monthly allowance, when in reality it should be 10 - because the file consists of 10 steps.

I hope this is clearer?

I am using S3 yes, but the download count is still counted by s2…so I am not sure the relevance of this point?

I do not know how else this could be achieved, but if you have an alternative suggestion I am happy to consider it.

Thanks Ed

Oh, I think I now got what you’re trying to do.

Hmm… Well, your developer would need to find where s2 is updating the download counter, and for those files increae by 10 instead of 1. He could have the zip file name mention how many files are in it, as he suggested.

He’d probably also have to update the part the checks if the user still have downloads left, because s2 will thiink it’s fine if he has 1 left, but it should not be if he’s trying to download 10 in one go like that.

Does that help? :slight_smile:

Hi @ed.riley - could you explain your business model. This seems to be more a charging issue than a technical issue. Is your download limit an anti-pirating business objective or do you charge per download?

Thanks Christian,

Yes we understand we will need to update the download counter, that is pretty much where my developer got to. Here is what he said:

We found the area inside WordPress where S2 stores the counter of downloads.What we haven’t been able to find is where those values are assigned. It seems the default way S2 works is to give each file download a count of 1, which is a normal behaviour as you’d expect. What your objective to me was to see if we can assign a different value to different types of file downloads, specifically a Zip file with multiple files inside it. Since there’s no way inside the WP admin area to assign that value to a file, my thought was to try to assign that counter value programmatically.

The place I tried was inside WP’s functions.php file, where I was hoping to be able to override that file value when the page with the file download was built. It’s pretty easy to do that, but I couldn’t find the API elements inside S2 to make that change. When I tried to force it, all of WP would crash and I’d get the “Something bad happened” screen.

After a few of those, I removed my code from functions.php.

Basically, the question for S2 is this: can you change the counter value of a file. If so, is it best to do it programmatically as a function? If we know the answer to that, we can adapt our code to read the file name, where my plan is to place a counter value. For example, we would have a file called Math-year1-group-file5.zip. That file would get downloaded as intended, but our function would fire on download and read the filename for the “file” string and capture the integer right after it (and before the dot.) That would be our value. It also means people making these files wouldn’t have to mess with anything in the WordPress backend, they could just name the file a certain way.

This method of reading the file name requires a step on file creation, but it will end up being much faster than grabbing the file from WordPress OR S3, unpacking it, counting the files, etc. With the volume of downloads you do, that’s a ton of bandwidth and CPU cycles open a zip file and then delete it right away.

Could you help by giving a bit more guidance please?

Thanks Ed

Hi Tim, I wouldn’t call it a charging issue. My customers pay for a yearly or monthly plan and get access to download x number of files on a 30 day basis. So, what I am trying to achieve is blocking together some of these files into a ZIP to make it easier for the customer, but I also want to protect my business. I don’t want the customer to sign up for a 3 months and basically download everything they want in ZIP files that only count as one download. Therefore, counting as multiples (the number of files in the ZIP) seems to be the logical way.

But of course, if I am missing an obvious alternative, then I am happy to explore suggestions.

There are always lots of options…it’s just ultimately up to you to choose. Custom code or re-aligned charging model or creative structure of data.

Example: Drip feed your bundles. So treat your zipfile bundles as unique products and make them available to subscribers via drip feed. Month 2 - 2-file bundle, month 3 - 3-file bundle.

Want mix-and-match bundles…drip-feed a protected form that allows them to only download n-files in a zipfile after n-months. Or, alternatively, drip feed them a coupon that can be used for a bundled download.

I’m not suggesting that these appeal to you…just examples of alternate ways to provide an outcome without custom code.

Bundled download is an extra bonus AND a risk to your business. I would treat it as such and make it available to loyal customers as a bonus rather than a routine feature to everyone who just signed up.

Just a suggestion :slight_smile:

I am a coder…but I have never had to write custom s2member code to accomplish my clients’ content protection needs.

Thanks for your input Tim.

Unfortunately, dripping content does not fit my business model at all.

I need to use custom code, which is fine. I just need to know the answer to my original question - hopefully Christian will be able to provide that.

Hi Ed.

If the question is whether it’d be possible to have the zip contents count in the name and use that, I believe so. I haven’t done it myself, but I don’t think I’d go opening each zip file to count files each time they have to be served. Adding the count to the name seems best. This can be used dynamically by your script when checking against the user downloads count and limit, and updating the count. I thought I mentioned this in my previous reply, but I guess I wasn’t clear, or I didn’t get the question…

Let me know if that helps. :slight_smile: