The “Membership Protected Content” shortcode can be selected from within posts, pages and products.
It allows you to set up different content for the same “post” (page or product) of each different membership plan: the system will automatically select the content to display to each customer, according to the type of membership they own.
Every content added within the shortcode will only be displayed to customers who own a membership plan.
Please, consider this shortcode has two different forms: an opening and a closing one. The restricted content has to be placed within the opening and closing shortcode.
Opening shortcode (setting the start of the restricted content):
Content to restrict in between
Closing shortcode (setting the end of the restricted content):
In the opening shortcode, you will be able to specify more details through the available attributes:
plan_id="": to restrict the content visibility to the members of one or more plans, you can add the plan ID attribute in the opening tag of the shortcode. To find the plan ID, go to "Memberships":
user="": this attribute defines the type of user that can view the content, and so change the way the restricted content works. By default, it is set to member, but all available options are: member, non-member, guest, logged.
[membership_protected_content plan_id="123"] This content is only visible to members of plan 123 [/membership_protected_content]
Suppose you want to show the content to all non-members except for those who have the plan with id="123", you may want to compose the shortcode as follows:
[membership_protected_content plan_id="123" user="non-member"] All users except for those with the 123 plan will see this content. [/membership_protected_content]
Example 3 - Gutenberg blocks
You can also restrict access to one or more Gutenberg blocks, for example, if you have a video block.
In this case, you'll have to compose your blocks as follows:
- one block to add the opening shortcode
- one block with the content to restrict (for example the video block)
- one block to add the closing shortcode
As you can see in the screenshot below: