This Pro tutorial provides the steps to restrict Pages and individual elements like Sections in Bricks depending on whether the current user has any active membership (free or paid) or any active paid membership or has access to a specific membership level when using Restrict Content Pro.
After implementing the tutorial, you can
- assign a class of
has-active-membershipto an element for it to be output only to members that have at least one active membership – free or paid. - assign a class of
has-paid-membershipto an element for it to be output only to members that have at least one active membership for a paid membership level.
and use Dynamic data condition like
{echo:bl_has_rcp_membership_level(1)}
for an element to be output only if the current user has access to the specified membership level i.e., 1 in this example.
Content from the block editor is automatically protected by Restrict Content Pro.
If your Page Bricks template is set to also show Bricks content (as it should), note that out of the box it will be visible to everyone and not just to the members that should have access to it per what’s set at the Page level via the “Restrict this content” meta box.
After adding the following code, you could simply add has-active-membership or has-paid-membership class to the Post Content element that’s set to show Bricks content in your Page template at its STYLE → CSS → CSS classes to have the Bricks content be output only to members that have any active membership or any paid membership.
Step 1
Add the following in child theme‘s functions.php (w/o the opening PHP tag) or a code snippets plugin:
// Output elements based on their class when using Restrict Content Pro.
add_filter( 'bricks/element/render', function( $render, $element ) {
// if Restrict Content Pro is not active, render the element
if ( ! class_exists( 'Restrict_Content_Pro' ) ) {
return $render;
}
// get the element CSS classes
$classes = ! empty( $element->attributes['_root']['class'] ) ? $element->attributes['_root']['class'] : false;
// check if the element has the special class "has-active-membership"
// if so render the element only to members that have at least one active membership (free or paid).
if ( $classes && in_array( 'has-active-membership', $classes ) ) {
return rcp_user_has_active_membership();
}
// check if the element has the special class "has-paid-membership"
// if so render the element only to members that have at least one active membership for a paid membership level.
if ( $classes && in_array( 'has-paid-membership', $classes ) ) {
return rcp_user_has_paid_membership();
}
return $render;
}, 10, 2 );
// Function to check for a specific membership level when using Restrict Content Pro.
function bl_has_rcp_membership_level( $level_id ) {
// if Restrict Content Pro is not active, render false
if ( ! class_exists( 'Restrict_Content_Pro' ) ) {
return false;
}
return in_array( $level_id, rcp_get_customer_membership_level_ids() );
}
Step 2
Page Restriction
As mentioned earlier, add has-active-membership or has-paid-membership class to the Post Content element that’s set to show Bricks content in your Page template at its STYLE → CSS → CSS classes to have the Bricks content be output only to members that have any active membership or any paid membership.

Element Restriction
This can be done by adding has-active-membership or has-paid-membership class to the element or by applying a Dynamic data condition with == 1 for true or != 1 for false.

{echo:bl_has_rcp_membership_level(1)}
The number in the parenthesis is the ID of the membership level.
1 in the last field in the condition dialog represents true.
References
https://help.ithemes.com/hc/en-us/articles/360049324614-Restricting-Content-in-Template-Files
https://help.ithemes.com/hc/en-us/articles/360053115813
https://help.ithemes.com/hc/en-us/articles/360052346914-rcp-user-has-paid-membership-