Show Gutenberg Blocks by User Role

Restrict Content by User Roles on a Gutenberg Block
Restrict Content by User Roles on a Gutenberg Block

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.

This is a premium condition to change the visibility of WordPress content using Conditional Blocks Pro.
(P.S This block is a Reusable Block + Conditions. It won’t be shown if you’ve purchased 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.

  1. Make sure you have Conditional Blocks Pro installed.
  2. Click on any block in Gutenberg and navigate to the sidebar.
  3. 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.

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 with their account. The “customer” role will automatically be picked up by Conditional Blocks.