Restricting content by user roles in WordPress is a popular requirement for memership type sites. You may want to show exclusive content to your members or customers depending on their role.
Available in Conditional Blocks Pro
How to restrict blocks by user roles
Good news! Conditional Blocks for Gutenberg makes it easy to restrict content by user roles. It’s also fully compatible with any membership plugin. As long as the user rule is registered inside WordPress then Conditional Blocks will automatically detect custom user roles.
- Make sure you have Conditional Blocks Pro installed.
- Click on any block in Gutenberg and navigate to the sidebar.
- Select the user roles that are allowed to view the block.
You can multiselect or deselect user roles by clicking while holding
command on macOS or
Control on Windows.
That’s all you need to do. Your block content will now only show for the specifed user roles.
Will this work with custom user roles?
Yes! This method of hiding content based on WordPress user roles will work with any plugin that add custom user roles.
As an example, WooCommerce customers will have the role of “customer” automatically assigned with their account. The “customer” role will automatically be picked up by Conditional Blocks.