Restrict Content Pro in Bricks

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-membership to 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-membership to 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:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 526 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
How to Inject a Different Type of Post in Bricks Query Loop

How to Inject a Different Type of Post in Bricks Query Loop

Updated on 26 Aug 2024 A user asks: Hello, I'd like to inject a CPT post card inside of a Bricks query loop of a different CPT…
How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

How to create filters with IsotopeJS in Bricks (Part 4): AJAX filter and infinite loops, Sorting, List view and Disable animations

This tutorial will explain how to enable the AJAX filter with an infinite scroll query loop container, how to add a sorting function, how to…
Categories:
How to Add a Custom Control Field to an Element in Bricks

How to Add a Custom Control Field to an Element in Bricks

In this tutorial, we'll learn how to add a custom control field to an element and dynamically change a CSS property inside the builder. Introduction…
Categories:
Tags:
Filtering out Media Items from “Select post/page” Bricks control

Filtering out Media Items from “Select post/page” Bricks control

The dropdown that appears after choosing "Internal post/page" when setting a link in Bricks shows media (attachment) items besides Pages, Posts and other CPTs. If…