Today we’re going to look at restricting downloads to members inside WooCommerce. I’m going to assume you’ve got some members and want to provide them with downloadable resources but you don’t want everyone to be able to download them.

We’re going to need three plugins to make this easy.

First, WooCommerce is installed. We’ll use WooCommerce to sell our products and subscriptions.

Second, Easy Restricted Content for WooCommerce. This is a plugin I wrote and is the simplest way to build a membership site on WooCommerce.

Third, you’ll need the WooCommerce Amazon S3 plugin. We’ll host our files on Amazon S3. This will secure them for us and get us out of the WordPress uploads folder which is hard to secure. Using S3 will also mean that we don’t have to worry about crushing our server if all our members download files at the same time. That means you’ll also need an S3 Account. Sign up for one now. They’re very inexpensive for hosting your files.

If you don’t have an S3 account, pause now and create one because I’m going to start assuming that you have our account created.

You should also have your product or subscription setup already in WooCommerce.

Setup WECR

Now, let’s start by adding a ‘members content’ page. Here is where we’ll host the links for our downloadable content for members.

We’ll need to restrict access to the page to people that have purchased our products or are valid subscribers. Click on the “restrict content” box on the right side of the page and select the products that you want members to purchase to see the content on this page.

If you want this page to show on the Account Page for your members, then leave the “remove content from My Account” checkbox empty. You might do this as a single spot that members can go to find the links to their custom content.

Now click the publish/save button on your page to make sure that your content is live where members can view it.

Setup S3 Plugin

Our next step is to setup the plugin that interfaces with S3. Open up your Amazon account in one tab of your browser and the S3 configuration settings in another.

You can find the settings under the WooCommerce Menu on your site.

We have four fields/options here. The first two are your access keys. They’re long numbers that Amazon generates for you so that you can securely access your S3 bucket without others being able to access it. We’ll go over how to get those in a second.

Third is the option to serve HTTPS or secure files. You should check this so that you only serve files over HTTPS.

Finally, you’ll need to set the URL valid period for the download links that are built by the S3 plugin. It’s set in minutes. I usually use set it for 1000 minutes which means that a URL is valid for just over half a day. If you’re having issues with people sharing the links generated for your content, change this to a lower limit so that the links don’t live as long.

Now, let’s get our two keys from our S3 account.

You can find a link to the documentation for setting up your S3 keys in the here.

Setting up the URLs for your site

Now that we’re setup with our S3 account, we’re ready to set up our custom download URLs. Go to the members page you created and create a link in the WordPress editor.

In the link field, add the shortcode that the WooCommerce S3 plugin uses.

You’ll need to get the link to the resource and you’ll need to know your bucket name.

You can get the link to your resource by going to your S3 account, navigating into your bucket and then clicking on the resource you want. On the right side you’ll see a popup. Here you need to click “copy path”. That will put the path to the file inside your bucket in your clipboard.

Now got to your shortcode. There are two parameters we need to add for it to work. First, we need to add our bucket name. Second we’ll need to link to the resource we just copied.

You can see that my bucket name is sfnmembersscreencasts. The resource path is becoming-master.pdf which links to a book that I provide to members on my site at curtismchale.ca.

The shortcode we just setup will generate the URL we want for our download.

That’s it, we now have a download URL for members that is only accessible on a single page that is restricted to members.

If you have other questions about building membership sites, leave a comment to let me know what you’d like me to talk about.

Posted by Curtis McHale