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.

Integration with Third-Party Plugins

Using Conditional Blocks Pro to restrict content by user roles is not only limited to the default WordPress user roles. The plugin can also work seamlessly with third-party plugins that add custom user roles or manage memberships. In this section, we will explore the compatibility of Conditional Blocks Pro with popular plugins like Membership Plugins, WooCommerce, and User Role Editor.

Working with Membership Plugins

Many WordPress membership plugins, such as Restrict Content, Paid Memberships Pro, and MemberPress, create custom user roles to manage access levels for their members. Conditional Blocks Pro can automatically detect these custom user roles and allow you to use them in your visibility conditions. Simply follow the same steps mentioned in the basic setup section, and the custom user roles created by your membership plugin will be available for selection.

Compatibility with WooCommerce

WooCommerce is a popular e-commerce plugin for WordPress that assigns a “customer” role to users who create an account during the checkout process. Conditional Blocks Pro can easily detect the “customer” role and allow you to restrict content based on this role. This is particularly useful if you want to display exclusive content, offers, or discounts to your registered customers.

To restrict content for WooCommerce customers, follow these steps:

  1. Click on any block in WordPress Block Editor (Gutenberg) and navigate to “Configure Visibility Conditions”.
  2. Select the User Roles condition rule and choose the “customer” role from the list.
  3. Configure the block action as desired (e.g., show or hide the block for customers).

Custom User Roles and User Role Editor

WordPress plugins like User Role Editor allow you to create and manage custom user roles with specific capabilities. Conditional Blocks Pro can also work with these custom roles, providing you with the flexibility to restrict content based on your unique requirements.

To use custom user roles created with User Role Editor, follow the same steps outlined in the basic setup section. Your custom user roles will be available for selection in the User Roles condition rule.

In conclusion, Conditional Blocks Pro integrates smoothly with various third-party plugins, making it a versatile solution for restricting content by user roles in WordPress. Whether you’re working with membership plugins, WooCommerce, or custom user roles, Conditional Blocks Pro has you covered.

Was this page helpful?