This question comes from Emily:

How can I restrict products to members so that only members can purchase them? Our site is a club that only offers purchasing to registered members, and customers that aren’t members must sign up before they can purchase.


Unfortunately, most people want to be able to list products in their shop catalog so that non-members can see them, but limit purchasing only to members. You can obviously do this with custom code, but finding a solution that works as-is is difficult. It can be done using Exchange (which we have an upcoming tutorial on), but the ability to hide products from non-members is fairly easy.

Let’s go through how you can restrict products to members only and prevent access to them from non-members using the Groups plugin and the Groups 404 Redirect, both of which are free plugins. Members will still be able to see and purchase these products normally, but non-members can be blocked from them (products will be hidden) and redirected to a signup page.

Restricting Products to Members Only

First, let’s see what needs to be done with Groups. When you install the plugin, you’ll want to go to the Groups > Options page to ensure that you’re able to restrict products. As most eCommerce plugins add your products as custom post types, Groups will be be able to restrict access to them. For example, Groups has noticed that I’m using Easy Digital Downloads on one test site, and allows me to restrict my Downloads if desired:

Groups Restriction Options

Side note: this is really handy for restricting access to media files as well if this is something you need.

Make sure that your “Downloads” or “Products” post types can be restricted so that we’ll be able to enforce access restrictions on our products.

Next, you’ll want to make sure you have the right capabilities accessible. Add a capability for your members by going to Groups > Capabilities and clicking “New Capability”. For example, I created “basic”, “silver”, and “gold” capabilities, which correspond to my membership level access levels I’ve already created in my membership plugin (this is important – we’ll need to tie these capabilities and groups to the appropriate members later). If you’re using WooCommerce or Jigoshop, Groups probably is your membership solution, so you won’t have to worry about this.

Add Member Capability

Now create a group. This group can be assigned the capabilities you just created. I made Basic Members, Silver Members, and Gold Members groups. As I’m using a tiered membership, basic members only have the “basic” access capability, silver members have “basic” and “silver” access capability, and gold members have access to all capabilities.

Create a membership group

Go back to the Options page. Scroll down to “Capabilities” and ensure that you can limit access using the new capabilities you’ve just created. This will make sure you can select the appropriate capability on the product page.

Groups Set up capabilties

If you’re using WooCommerce, you can actually do even more than this with the Groups for WooCommerce extension – see our article on Membership sites with WooCommerce for more info.

Now that you have restriction capabilities set up, you can add them to your products. In your product page, you’ll now see a meta box for Access restrictions. If you enable the appropriate capability restriction for this product, non-members will not be able to view the product. As I only want Gold Members to be able to purchase restricted products, I’ll only add that capability.

Restrict Access to Membership

Restrict Access to Membership

If you’re using Groups for WooCommerce, you can also bulk add restriction rules from the “Products” page by checking the products you want to restrict, then bulk-adding restrictions:

Bulk add restrictions in WooCommerce

Bulk add restrictions in WooCommerce

Awesome! Really easy.

There’s just one teeny-tiny problem. Non-members can’t see anything, so if they try to visit your product page from a link or elsewhere on your site, they’ll just see your 404 page. We’ll have to make sure we create a landing page and send them there instead so they can purchase a membership.

Setting up a Landing Page for Non-members

This is where the Groups 404 Redirect plugin will come in. First, make a landing page to send users to when they don’t have the correct access level to purchase a membership. Unfortunately, you can’t change where members are redirected depending on which level is required, so you’ll have to have one descriptive landing page for all of your membership levels. Obviously, you could customize this with some custom code, but this may work for many of you in the meantime. If you’re only using one membership level for restricting product purchasing, that’s probably not relevant for you. Carry on 🙂 .

I’ve set up a quick sample page where I’ve linked to product pages for each membership, but you may want to include details about each membership so customers can quickly find the right one:

Groups Redirect Page

Pay attention to the post_id for this page – you can find it really easily by looking at the URL in your address bar while you’re viewing it. You’ll see something like this: http://test.com/wp-admin/post.php?post=428&action=edit. The part that says ?post=428 is what I need.

Now we’ll set up the redirect to this page. Make sure the Groups 404 plugin is installed, then go to Settings > Groups 404 and enter this ID for the redirection:

Groups 404 Redirect non members

That’s it! Once you do this, customers will be directed to this landing page instead of a 404 page if they try to view a product they can’t purchase.

There’s one more thing we’re forgetting before we’re done – can you guess what it is?

Tying Groups to Members

Final step – technically everyone right now is a non-member, as you don’t have anyone assigned to your groups. If you’re using Groups for WooCommerce or Groups for Jigoshop, this is already done for you when customers purchase access to your membership group. You tie groups access to your WooCommerce or Jigoshop products when created, so purchasing triggers addition to the appropriate group.

If you’re using a different eCommerce and/or membership plugin, you’ll need to tie group access to the appropriate members since it doesn’t happen upon purchasing a membership.

Go to the “Users” menu. Unfortunately, we’ll have to do this manually and keep adding groups to new members manually if you use something other than WooCommerce or Jigoshop + Groups. If you have tons of members, you can hire a developer to customize this process to add groups automatically to membership purchases since the development costs will probably make sense for you to automate this process.

You can add groups to individual users by viewing the user’s profile and adding a group at the bottom:

Add Group to User

Add Group to User

You can also do this in bulk (which I’d recommend) by selecting the users that require this purchasing group, then using the bulk Groups actions at the top of the page:

Bulk Add Users to Groups

Bulk Add Users to Groups

I’m bulk-adding every person that’s bought a gold membership (I got a list of gold members in my membership plugin) to my gold-level purchasing group to sync this up with my product restriction.

Now your members are tied to the appropriate purchasing group, and these members will be able to view your protected products when logged in, while non-members cannot.

Take it Further

You could get a bit trickier with this to show restricted products in your catalog by creating a public product to show in your catalog, then redirecting that to a private one. For example, you could set up the public product as an external/affiliate product, then link to the restricted product. FYI, there’s a free EDD add-on for this.

This way, non-members see something in your catalog and are redirected to a signup page, while members will just be able to purchase. Unfortunately, this means members that are logged in will see both products in the catalog, so it’s not exactly ideal either.

This tutorial and usage doesn’t provide the smoothest solution to this problem, but it’s a free one that anyone can set up to restrict their products to members only using almost any eCommerce plugin.

Articles you may also like:

Posted by Beka Rice

Beka Rice manages the direction of Sell with WP content and writes or edits most of our articles to share her interests in eCommerce. Or she just writes as an excuse to spend more time jamming out to anything from The Clash to Lady Gaga. Who knows.

8 Comments

  1. Hi Beka,

    I am filling this comment after reading your article “Ask Sell with WP: How to resrict products to members only”. I may be wrong but I have taken this as an invitation to ask your opinion on the suitability of the Groups plugin to meet my web site needs. Hopefully I am correct.

    I do not sell memberrships. I sell wholesale products. I wish to protect all aspects of my web site from an potential customer but would be happy to have that potential customer directed to either my Contact page or a Registration feature as long as my approval is necessary before that person can dsign in. Protection would include the Menu and the Search capability. My enviroment is Woocommerce and Mystile theme. If I was to use the Groups plugin there would only be one tier of membership (lets call it Registered) and all products would be available to view and purchase by a Registrered Customer.

    Here’s hoping to hear from you soon. Best Wishes. David.

    1. Hey David, I think Groups would probably be a great fit for this, as it still has all of the management capabilities you want in terms of restricting products (even if you’re not selling the access to those products, but instead giving it away). If you’re okay with showing products but not allowing purchase, you may also find this helpful: https://www.sellwithwp.com/store-customers-only-woocommerce/

  2. Thank you Beka, this was very helpful. I’m setting up a woo commerce wholesale buyers club for gluten free things: http://wholesale.glutenfreethings.com that includes a membership or subscription style access. My client purchased woo commerce subscriptions so hopefully with your intelligent iterations plus the subscription plugin I’ll be flying with the geese.

    THANKS AGAIN!

    mary

  3. Hi Beka,
    I’ve been working through your article and have realised that I really want visitors to see my products, but are required to register before purchasing. Do you happen to have any suggestions?

    Kind Regards,

    Kev

    1. Hey Kevin, we’ve got an article on creating a customers-only store with WooCommerce that should help 🙂

  4. Hi Beka, that’s what I was looking for thank you!

  5. Hi
    I just tried this at my webshop, which is for registered wholesale customers only. However, I am also running a WPML – multilanguage plugin, and somehow the original language products are hidden from non-users, as they should be, but the translations are still visible to non-users.
    Do you know of any ways to fix this? I am not given the same options for editing the translations of the products, so the box that i filled out with the rule for the original product, isn’t there in the translated version.
    Hope you can help me
    Best regards,
    Sofie

    1. Hey Sofie, I’d recommend submitting a help request so someone from the dev team can help get this patched up for you.

It's been over 2 years since this post was published, so comments have been closed. Thanks for reading!