Primary

Content Sections

Groups helps you to protect access to your pages, but you can also use it to protect sections of content within pages. With the Blocks and Shortcodes provided, you can protect parts of your posts, pages, products and content in other post types.

This means that you can leave access to some pages with protected content open to anyone, and instead of protecting the entry completely, you could show only parts of it.

You can protect sections of content so only group members can view them, but you can also hide content sections from group members.

Groups allows you create an unlimited number of groups, so you can create as many as needed for different teams, classes, organizations or whatever classification you might want to use to group your users. It also provides a default group named Registered, which is useful to show or hide content depending on whether a visitor is logged in or not. This group can be used just like any other group to show content sections conditionally.

Protecting Content with Blocks

Groups provides Blocks that are used to show content based on memberships.

  • The Groups Member block reveals the content it encloses to group members.
  • The Groups Non-member block hides its content from group members.

The Groups Member block in the following example uses a group named Premium to restrict access to its content.

The block can contain any composition of inner blocks, so it allows you to build more complex structures that are protected. In the above example, the content that is protected by the Groups Member block is composed of a Group block which contains several Paragraph blocks:

The Groups Non-member block in the next example uses the Basic and the Premium group to hide its content from members of any of those two groups.

You can also create compositions that reveal content conditionally within, as the membership blocks can be nested.


Protecting Content with Shortcodes

Groups provides Shortcodes that are used to show content based on memberships.

For content compositions that rely on shortcodes, these can be used to protect sections of content within pages.

The above example uses two shortcodes to render content conditionally, based on the visitor’s membership. The first content section is shown to members of the Premium group only. The section below that is shown for those who do not belong to the Premium group.

A visitor who is a member of the Premium group will see the page content like this:

Whereas a visitor who is not a member, will see the alternative content provided by the second section:

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 not nest two instances of the same shortcode, as how these are interpreted by WordPress is limited. This is true for any shortcode, not just those provided by Groups.

The following example uses several membership shortcodes: