Limit access to page sections

In addition to being able to restrict whole posts and pages, you can also choose to restrict only select sections of the content.

 

Restriction Shortcode for Levels

If you have a level with the name “platinum”, you can hide a section for unauthorized users with the following shortcode:

[restrict level="platinum"]

This content can only be seen by users with Platinum level or above.

[/restrict]

 

Likewise, if you want to hide a section for level members, use the following code (notice the !):

[restrict level="!platinum"]

This content can only be seen by users without Platinum level or above.

[/restrict]

 

Good to know: As with conditional restrictions, administrators are by default able to see all content hidden by restriction shortcodes.

 

Restriction Shortcode for User Roles

If you have a User Role with the name “subscriber”, you can hide a section for unauthorized users with the following shortcode:

[restrict role="subscriber"]

This content can only be seen by subscribers.

[/restrict]

 

It is also possible to add several roles to the same shortcode:

[restrict role="contributor,editor"]

This content can only be seen by contributors and editors.

[/restrict]

 

Was this article helpful to you?