27th Nov '22
/
4 comments

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 610 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

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…
Pro
x Number of Random Bricks Query Loop Items(s) to be Shown Every x Hours

x Number of Random Bricks Query Loop Items(s) to be Shown Every x Hours

Showing how to display one random row of a Meta Box group for an hour and then output another random row.