With Groups, you can protect parts of your posts, pages and content from other post types. Instead of protecting an entry completely, you could show only parts of it. This makes the entry still visible to anyone but hides certain parts from normal visitors, users who don’t belong to the right group. In addition, you can also hide content from group members. Besides protecting parts of your content based on groups, you can also use capabilities to decide whether a section should be shown or not.
So, how is this done? You can edit your entries as usual – Groups allows you to limit the visibility of as many content sections as you like by simply enclosing them within shortcodes.
Let’s have a look at a simple example:
Here's some unprotected content. Anyone can see this. [groups_member group="Registered"] But this section is different, only registered users will see this. [/groups_member] Here's some more content which anyone can see. [groups_member group="Premium"] And this section is shown only to users in the Premium group. [/groups_member]
Please copy the above and past it on page. Now visit the page while logged out (you can simply use another browser than the usual one) and you will see the content is limited. Now log in as a normal user or if you have created the Premium group, log in with an account that belongs to it. In both cases, you will see more based on the account’s membership.
This is what our editor shows after pasting the example on a new page:
For someone who is not logged in, this is what the visitor will see:
The content section that is protected and only shown to registered users who are logged in will show more. A registered user will see the protected content section:
And a member of the Premium group will see everything:
You can use as many instances of the shortcodes used to protect content sections on the same page and on as many entries you want.
You can also nest shortcodes as long as they are different. You can’t nest two instances of the same shortcode because the way these are interpreted by WordPress is limited. This is true for any shortcode, not just those provided by Groups. Anyhow, here’s an extended example with different shortcodes, including a nested section:
You are connected!
Why don't you join the Premium group?
[groups_can capability="manage_options"]You've got the power![/groups_can]
This is how it looks like in our editor:
That’s how the page will appear to a simple visitor:
And here is what a registered user sees:
What a Premium member sees who also has the manage_options capability: