WooCommerce Memberships provides several methods for restricting content on your site. You can restrict content while creating or editing a membership plan, by adding rules from the Memberships meta box while editing content, or by using a shortcode.

Note that if no rules are applied to content, that content is publicly accessible. Once a rule has been applied to content, that content is restricted, and only accessible to memberships that grant access to that content.

Rules hierarchy: which rules override others

There are situations in which restriction rules could overlap. For example, you could have a restriction set that members can access the “Coffee” category of posts, but only after 1 week has passed. All posts in this category will now abide by this rule.

However, if you also create a rule for the “Moka Latte” post in the “Coffee” category, you could say that this post is restricted, but accessible immediately. This introduces a conflict, as both of these rules apply to the same content.

When this occurs, Memberships always defers to the more specific rule. In this case, the post will be accessible immediately, because a rule for the post is more specific than a rule for the entire category.

Here are the basic rules that Memberships follows:

  • Rules that restrict an entire content type, such as all blog posts, are put into effect first.
  • They can be overridden by more specific rules. You can restrict all blog posts, but then set rules for categories or single posts.
  • A rule for blog post categories or tags (taxonomies) will override a rule for all posts, as it is more specific.
  • A rule for a single blog post or group of posts will override both rules for an entire content type and for a taxonomy, as this rule is most specific.
  • If two rules are of equal specificity, the rule that grants access first will be followed *.

*Example: If a post is in both the “Marvel Superheroes” and “Avengers” categories, rules could be applied to both of these categories that conflict. If “Marvel Superheroes” is accessible after two weeks, and “Avengers” is accessible after one week, the post will be accessible in one week. The earlier access rule will always be used.

This can help you expedite setup, as you may want to delay access to a category, but provide access to one or two posts immediately.

Membership plan page

Restricting content while creating or editing a membership plan provides the most control over content restriction. While editing a plan, you can restrict all pages, posts, categories, or other types of content easily.

WooCommerce Memberships content restriction

You can also create specific restriction rules for individual posts, pages, or taxonomies (such as categories), and determine when members should get access to this content (immediately or after a certain time has passed).

You can learn more about creating plans in the Membership Plans document.

Product restriction

Product restriction is unique because either viewing or purchasing restrictions can be used. Products can be restricted from the plan page as described above, but they can also be restricted while editing the product.

Because products can both grant access to memberships, as well as be restricted by memberships, the product meta box is slightly different from the default Memberships meta box.

To restrict a product while editing it, view the “Memberships” box, and go to “Restrict Content”.

WooCommerce memberships restrict product

You can create a rule here that will restrict this product to the selected plan, just as if it were added from the plan page.

Note that if you already have restrictions in place that affect more products (i.e., a category-level restriction that affects this product), you cannot edit it from here and must edit it from the plan page.

WooCommerce Memberships rules disabled

Content restriction

The Memberships restriction meta box will be added to your pages, posts, and other content while Memberships is active. This will allow you to add membership restriction rules on the fly as you edit or create content.

WooCommerce Memberships content meta box

To restrict a page or post while it’s being edited, simply add a rule to restrict the content to a particular membership plan.

WooCommerce Memberships content restricted meta box

You can also use custom restriction messages if you’d like to tailor the restriction notice to this content. If enabled, this will override the default / global restriction message set under WooCommerce > Settings > Memberships > Messages.

Making content public

If you’ve restricted content, you can still make it public (version 1.1+). While viewing your post, page, product etc., you can disable restrictions. This overrides any and all rules that apply to the content, making it publicly accessible for everyone. This can be done from the “Memberships” meta box while creating or editing the content.

WooCommerce Memberships Make content public

This is an easy way to make teaser content public. For example, you could restrict all posts with a single rule, and then use the “Disable restrictions” option to make some public as a teaser for your membership.

If you have public content with restrictions disabled on your site, this will be listed on the membership plan page for reference.

WooCommerce Memberships Public Content

Restrict content with Memberships Gutenberg blocks

You can use Memberships blocks in the Gutenberg editor to easily restrict content to members and non-members.

  • The Member Content block restricts content to plan members. You can specify which plan(s) a user must belong to in order to see the content, as well as determine when this content should be visible.
  • The Non-Member Content block restricts content to visitors and other non-members. You can specify certain plans that a user must not belong to in order to see the content.

Using Member Content blocks

Follow the steps below to setup a Member Content block for a page or post:

    1. Click Add Block and select the Member Content block.
    2. In the Block settings panel, you’ll see the following options:
        • Membership plans: Specify one or more plans that a user must belong to in order to see the restricted content. If left blank, members of any plan can see this content.

        • Delay access: Determine when members can see this content – immediately, after they’ve been a plan member for a certain length of time, or after a specific date. If you’re using WooCommerce Subscriptions, you can also hide this block until after the free trial period.

        • Restricted content message: Decide what users who do not have access to this block should see instead of the restricted content. By default, the block will be invisible to those without proper access, but you can also use your default restriction message or create a custom message.

    3. You can add text or insert other blocks inside the Member Content block. All content within the block will be restricted based on your block settings.

  1. When you’re satisfied with your page or post, click Publish. You can visit the site to see how it will appear to members, or visit the page in an Incognito window to see how it will appear to non-members.

Using Non-Member Content blocks

Follow the steps below to setup a Non-Member Content block for a page or post:

    1. Click Add Block and select the Non-Member Content block.
    2. In the Block settings panel, you’ll see the following options:
        • Membership plans: Specify one or more plans that a user must notbelong to in order to see the restricted content. If left blank, users who don’t belong to any plan can see this content.

    3. You can add text or insert other blocks inside the Non-Member Content block. All content within the block will be restricted based on your block settings.

  1. When you’re satisfied with your page or post, click Publish. You can visit the site to see how it will appear to members, or visit the page in an Incognito window to see how it will appear to non-members.

Restriction shortcode

The [wcm_restrict] shortcode provides an easy way to restrict blocks of content within a page or post. This is most useful when you don’t want to restrict and entire page or post, but portions of the content should only be visible to members, such as tutorial videos or infographics. This will not show a restriction message, so you can use the non-member shortcode if you’d like to add a restriction message.

There are three accepted attributes, but they are all optional:

  • plans: the plan slugs or IDs to limit the wrapped content to certain members
  • delay: delays access to the wrapped content by a certain time, or makes it available on a particular date
  • start_after_trial: delays access to the wrapped content until a trial period is over (when WooCommerce Subscriptions is in use)

Wrapping the content in this shortcode will hide it unless the member is logged in and has the appropriate access. Here are some ways this shortcode can be used:

Restrict content to members only

When used it its most general form, this shortcode will restrict content to any member on your site, regardless of which membership plan the member has. The general format is: [wcm_restrict]Restricted Content[/wcm_restrict]

This is public content.

[wcm_restrict]
This content is only visible to members, regardless of which membership the member has.
[/wcm_restrict]

This content is now public again.

Restrict content to specific members

The shortcode can also accept an attribute to limit the content to specific members. We can add the “plans” argument to restrict this content even further to certain members: [wcm_restrict plans="gold, platinum"]Restricted Content[/wcm_restrict]

You must use the appropriate slugs for your membership plans, which can be viewed from the plans list or by editing the plan.

WooCommerce Memberships plan slugs

You can use the plan ID instead of the slug if preferred (which is the same as the WordPress post ID).

This is public content.

[wcm_restrict plans="gold, platinum"]
This content is only visible to gold or platinum members. Members with other plans or non-members cannot see this.
[/wcm_restrict]

This content is now public again.

Delay restricted content access

There are two ways to delay the access members have to content wrapped in the shortcode:

  • delay access for a length of time (e.g., 2 weeks)
  • delay access until a certain date (e.g., January 1, 2016)

Delaying access for a length of time can accept any time for the delay argument, such as: „3 days”, „2 weeks”, „1 month”, or „2 years”

[wcm_restrict delay="2 weeks"]
This content will be available to members of any plan once they've been a member for two weeks.
[/wcm_restrict]

Delaying until a date can accept several date formats, but we recommend using the ISO standard (yyyy-mm-dd). For example, you can use: „January 1, 2016” or „2016-01-01”

[wcm_restrict delay="2016-01-01"]
This content will be available to members of any plan on January 1, 2016.
[/wcm_restrict]

NOTE: If you use a time, such as „May 1” with no year, be aware that this access may reset each year. For example, this content will be available May 1, 2015 to December 31, 2015, then access will reset and the content is inaccessible again from January 1, 2016 to May 1, 2016. Please ensure that you include a year to be specific about the access date.

You can also delay access based on trial status.

[wcm_restrict start_after_trial="yes"]
This content will be available to all members except those in a free trial from a subscription. They will have access when the free trial ends and the membership moves from "Free Trial" to "Active" status.
[/wcm_restrict]

Using all shortcode attributes

Any or all attributes can be used at a given time to control content access and access delay. For example, you can use all three attributes to restrict access to particular members at a certain time:

[wcm_restrict plans="gold, silver" delay="1 week" start_after_trial="yes"]
This content is available to any silver or gold member one week after the trial period ends. If the membership doesn't have a trial period, access is simply delayed 1 week.
[/wcm_restrict]

Non-member shortcode

Since shortcodes do not display restriction notices, you may want to give your non-members a notice to log in or purchase a membership. You can do so with the [wcm_nonmember] shortcode, which displays portions of content only to non-members. Non-members are guest users or customers who are logged in, but do not have a membership.

The general format is: [wcm_nonmember]Non-member Content[/wcm_nonmember]

This is content everyone sees!

[wcm_nonmember]
Whoops, this video is for members only. If you have a membership, please log in. If not, you can definitely get access! <a href="/membership/">Purchase a membership here</a>.
[/wcm_nonmember]

[wcm_restrict]
Embedded video displayed to members only.
[/wcm_restrict]

Now we're talking to everyone again.

Specifying plans

The non-member shortcode can specific plans if you want to alter its behavior slightly. If you add a “plans” attribute, this will no longer only target non-members; rather, it will target all visitors who are not active members of the specified plan(s).

An example:

[wcm_restrict plans="gold"]
Content only shown to gold members
[/wcm_restrict]

[wcm_nonmember plans="gold"]
Content shown to anyone who is not a gold member, even other members
[/wcm_nonmember]

You can enter a list of one or more plans in this shortcode:

[wcm_nonmember plans="gold, silver"]
This is shown to anyone who does not have a silver OR gold membership active.
[/wcm_nonmember]

Upgrade prompts

When paired with [wcm_restrict] to target certain plans, you can dynamically display content appropriate to the member’s level. Remember, if a member has multiple memberships, they may see multiple messages.

Here’s an example of building a page that shows content only to certain members:

[wcm_nonmember]
Hey there! You've stumbled onto a members-only video :). If you'd like to check out this video, please purchase a Platinum Membership.
[/wcm_nonmember]

[wcm_restrict plans="silver, gold"]
Hey Member! Thanks for checking this page out -- however, it's restricted to Platinum-level members only. If you'd like to access it, please purchase to a Platinum Membership.
[/wcm_restrict]

[wcm_restrict plans="platinum"]
The super secret video for platinum members goes here.
[/wcm_restrict]