Content Protection - YourMembers/yourmembers GitHub Wiki
Content protection is Your Members' most important feature. It's the one thing that prevents people from accessing the content they shouldn't be accessing. In short, it keeps your exclusive content...well, exclusive.
To use it, however, you need to know a bit about this terminology and think about how you're going to use this powerful feature on your site to create and mould your business. To do that, you need a bit of information. Most importantly, the difference between a "package account type", a "package" and an "individual purchase"
The package account type defines what content users in that type can see and not see. When using Your Members for membership management, each person is assigned a package account type. Some package account types are already set up for you:
Guest -- For people who visit your site, but are not logged in.
Free -- Only available if the free module is active, the Free package account type includes all those who are registered, but currently don't have access to premium (or higher levels of) content.
Member -- This is a user-defined level created to show you what additional package account types could look like. For example, this package account type could include only users who have purchased access. You can delete this one, if you'd like.
Feel free to add more package account types and customise everything to meet your needs and make your membership site work best for you. Here are a few ideas:
- Gold, Silver and Bronze packages
- Premium and Basic packages
- Package account types divided by category or content type
It doesn't matter how creative you get with the package account type names or what you end up calling them. The names simply help you and your users tell the package account types apart from each other, so don't worry. Have some fun with them and make sure they work for you.
Just one thing to keep in mind:
Package account types aren't arranged on a hierarchy! This means that, just because those with a 'free' membership can see certain content, doesn't mean "member" level users can see it. If you want both membership types to see something, you need to specifically mark it that way. However, this is great if you want to create content specifically for the purpose of getting 'free' members to join up and start handing over some cash.
A package is the payment plan associated with a user and a package type. So, when a user signs up, he or she chooses a package to subscribe to (the package becomes a subscription). Then, that user is assigned a package account type appropriate for that package.
Each package can only relate to one package account type and have only one duration. But, a package account type can have a number of packages associated with it. Confused? Here's an example:
- A user can subscribe to a package of $5 a month for a "member" package account type.
- Another user can subscribe to the $1000 ever 10 years package for a "member" package account type.
- A third user can choose a package of $4 every two months for a "member" package account type.
All three of these can exist at the same time, on the same type. Just make sure your math is right -- Your Members does NOT error check costs or the duration. It assumes that the human in charge can count, so make sure to double-check these.
All of the content you publish can be sold individually, in addition to selling them as part of a subscription or package account type. This means, if a user only wants to see one video or post, they can buy access to it at a price you choose (provided you checked this option when you published).
You can also group your content together into bundles, and offer each bundle up for sale at a specific price. And while the price may be determined by the package account type the content falls into, users can still buy an unlimited number of individual posts or content bundles (packs of posts).
[private]
[private_and]
[private_or]
[user_has_access]
[no_access]
[ym_user_is]
[ym_user_is_not]
[ym_custom_is]
[ym_custom_is_not]
Your Members uses shortcodes to protect content on your WordPress post or pages. The shortcodes range from the relatively simple [private] to the more detailed such as [private_and]. When combined or nested with each other, they can provide for powerful and dynamic content protection for your site.
-
Protection in its simplest form:
[private]
So, how do we use these shortcodes to protect your content? As you can see below, to use the [private] shortcode you just place your content between the start and end tags.

[private]This content will be hidden from those package types without access [/private]
The [private] shortcode is the most basic Your Members provided protection shortcode. Anything contained within the opening and closing shortcodes will be protected and only seen by members with package types ticked in the sidebar widget.
As can be seen from the image on the right, only those members with the Member package type will see the content. Others will see a notice explaining why they can't see it. You could include some text inviting members to join or upgrade. The default notice is shown below.
If you are having problems with your private tag showing take a look at our FAQ section.
All of the following shortcodes work in the same way as the [private] shortcode above - while in the text editor (be careful to switch to the text editor from the visual editor if that is how you normally create content) simply surround your content in the appropriate start and end tags. Below are some more shortcodes which are useful for protecting your content.
-
Advanced logic based protection:
[private_and]
[private_and#123] Protected content available to members with access to the page they are reading and a page or post with an ID of 123 [/private_and]
This shortcode allows for more selective refinement of the [private] shortcode. As in the previous example, the content would be available only to a member belonging to the Member package type provided the member also had access to page or post ID 123.
-
Advanced logic based protection:
[private_or]
[private_or#345] Protected content available to members with access to the page they are reading. or a page or post with an ID of 345[/private_or]
This is a similar shortcode to [private_and] however in this case only members belonging to the Member package type or having access to page or post with an ID 345 would see the content.
-
Only show to allowed members:
[user_has_access]
[user_has_access] Only members with access to the post or page will see this content. [/user_has_access]
This shortcode will show content within if the user has access to the post or page, if the user does not have access to that post then they will be shown no content at all. The argument post_id is optional and defaults to the post the shortcode is on, or the old style # notation maybe used.
[user_has_access post_id=12] Only members with access to the post or page with ID 12 will see this content. [/user_has_access]
[user_has_access#5] Only members with access to the post or page with ID 5 will see this content. [/user_has_access]
-
Alternate content to disallowed members:
[no_access]
[no_access] Only members without access to the post or page will see this content. [/no_access]
The opposite of user_has_access tag content within this tag will only be shown to users who do not have access to the user_has_access tags. This allows you to create additional sales or other information on pages for people who cant see the protected content.
The argument post_id is optional and defaults to the post the shortcode is on, or the old style # notation maybe used.
-
Member account based protection:
[ym_user_is]
[ym_user_is package=3] Protected content. [/ym_user_is]
If the member matches the relevant argument, show the protected content. This shortcode can use one of the following arguments:
-
package – a Package ID:
[ym_user_is package=3] -
package_type – a Package Type:
[ym_user_is package_type="free"] -
username – a Username:
[ym_user_is username="alan"] -
role – a WordPress role or capability:
[ym_user_is role="author"]
-
Member account based protection:
[ym_user_is_not]
[ym_user_is_not package_type="free"] Protected content. [/ym_user_is_not]
This is the reverse logic from the [ym_user_is] shortcode. The content will be shown to the member who does not match the shotcode argument.
-
Show content based on a users custom field:
[ym_custom_is]
[ym_custom_is first_name="tim"] Show content to only people with the first name Tim [/ym_custom_is]
[ym_custom_is country="GB"] Show content to only people who selected UK as their country during registration [/ym_custom_is]
ym_custom_is takes a single argument, the first part if the custom registration field name for example first_name with the value being what to test for. Important use the custom field name and not the label for the argument and remember it's case sensitive.
-
Show content based on a users custom field not matching:
[ym_custom_is_not]
[ym_custom_is_not first_name="tim"] Show content to only people with the first name not Tim [/ym_custom_is_not]
[ym_custom_is_not country="GB"] Show content to only people who did not selected UK as their country during registration [/ym_custom_is_not]
ym_custom_is_not takes a single argument, the first part if the custom registration field name for example first_name with the value being what to test for and return only if the value is not present. Important use the custom field name and not the label for the argument and remember it's case sensitive.
