Restricting Content within a Post or Page

The Restrictions extension comes with two shortcodes which can be used to restrict content within a post or page.

Requiring Users

You may use the [tml-require-user] shortcode in order to require a user to be logged in, or require a specific user to be able to view a piece of content.

In order to require any logged in user to view a specific piece of content, you wrap the content in the shortcode.

[tml-require-user]
Only logged in users can see this!
[/tml-require-user]

Likewise, if you would like to require a specific user by ID, you append id="123" to the shortcode.

[tml-require-user id="123"]
Only the users with the ID of 123 can see this!
[/tml-require-user]

Or, if you want to require a specific user by their user login, you append login="someuser" to the shortcode.

[tml-require-user login="someuser"]
Only "someuser" can see this!
[/tml-require-user]

If you want to require a specific user by email, you append email="[email protected]" to the shortcode.

[tml-require-user email="[email protected]"]
Only the user with an email of [email protected] can see this!
[/tml-require-user]

Note that with any of the above examples, multiple values can be set by using the "|" (pipe) character to separate them. For instance, [tml-require-user id="45|22|108"].

Finally, if you would like to display alternate content when the requirement is not met, you would use the following syntax:

[tml-require-user]
Only logged in users can see this!
[else]
Guests will see this!
[/tml-require-user]

Requiring Roles

You may use the [tml-require-role] shortcode in order to require a user to have a specific role or roles to view a piece of content.

[tml-require-role role="editor"]
Hi, editor!
[/tml-require-role]

You can target multiple roles by using the "|" (pipe) character to separate them.

[tml-require-role role="administrator|editor|author"]
Hello, people who can edit stuff.
[/tml-require-role]

Finally, if you would like to display alternate content when the requirement is not met, you would use the following syntax:

[tml-require-role role="administrator"]
Hello, administrator!
[else]
Administrators only!
[/tml-require-role]