User Roles

Restricting content by user roles in WordPress is a popular requirement for membership-type sites. For example, you may want to show exclusive content to your members or customers depending on their role.

We recommend reading this documentation first, then our guide on showing personalized content with WordPress User Roles.

How to restrict blocks by user roles

Conditional Blocks will make it easy to restrict content by user roles. It’s also fully compatible with any membership plugin. As long as the user role is registered inside WordPress, then Conditional Blocks will automatically detect custom user roles.

  1. Make sure you have Conditional Blocks Pro installed.
  2. Click on any block in WordPress Block Editor (Gutenberg) and navigate to “Configure Visibility Conditions”.
  3. Select the User Roles condition rule and choose the roles that should be able to see the block content.
Exreesnhot of adding user role visibility conditions to WordPress content.

That’s all you need to do. Your block content will now only show for the specified user roles.

TIP: You can select multiple roles for the condition. If the current user has ANY of the selected roles they will be allowed to see the block.

TIP: You can stack User Role conditions. Stacking conditions means the current user MUST have 1 role FROM EACH User Role condition. Otherwise, the block will not be displayed.

Block Action

The block action is used to determine what you’d like to happen if the current WordPress user matches the User Roles you’ve selected.

For example: If the current user is an Editor, then show or hide the block.

Will this work with custom user roles?

Yes! This method of hiding content based on WordPress user roles will work with any plugin that adds custom user roles.

Conditional Blocks user roles will work with third-party plugins such as Restrict Content, Paid Memberships Pro, or User Role Editor.

As an example, WooCommerce customers will have the role of “customer” automatically assigned to their account. The “customer” role will automatically be picked up by Conditional Blocks.

Was this page helpful?