LMS Builder
Build your own course inside of Brick Builder.
← How to build a course platform
Lesson 7 of 9 *
How To Add Protected Pages in Bricks Builder (Without a Membership Plugin)
Membership functionality Using Custom Fields And Bricks Builder Conditions
Updated January 2026: This lesson shows how to protect premium content in Bricks Builder using custom fields + conditions, and how to optionally protect entire pages using a lightweight PHP function.
If you’re building a course platform in WordPress, you eventually need membership-style protection. The good news is: you don’t always need a heavy membership plugin to protect your content.
In Bricks Builder, you can create “membership functionality” using:
- Custom fields (ACF / SCF)
- Bricks Builder Conditions
- User roles (Subscriber, SureCart Customer, Admin)
Quick Answer: How do you protect premium content in Bricks Builder?
Create a custom field for premium content, then use Bricks Conditions to show that content only when a user is logged in as a customer or subscriber. Optionally, add a small PHP function to redirect non-members away from protected pages to a “No Access” page.
FAQ (Quick Answers)
Do I need a membership plugin to protect content in Bricks Builder?
No. For many course platforms, you can protect content using custom fields and Bricks conditions based on user roles.
Can I restrict content for SureCart customers only?
Yes. You can show content only to users with the sc_customer role (and optionally also subscribers/admins).
How do I protect an entire page (not just a block)?
You can add a lightweight PHP function that checks a custom field like protect_page, then redirects unauthorized users to a “No Access” page.
Lesson Overview
In this lesson, we protect both:
- Blocks of premium content (using Bricks Conditions)
- Entire pages (using a custom PHP redirect function)
Main Points
- Add a custom field for premium/protected content
- Create a subscriber-only message (for non-members)
- Use Bricks Conditions for user roles
- Test as admin vs logged-out user
- Add optional full-page protection with redirect
Part 1: Protect Premium Content Blocks Using Custom Fields + Bricks Conditions
Step 1: Add New Custom Fields
In your custom fields plugin, add the following fields to your lesson post type:
- protected_text (WYSIWYG Editor)
- protect_page (True/False toggle)
The WYSIWYG editor is ideal because it allows you to insert:
- Text
- Links
- Buttons
- Downloads
- Graphics
Step 2: Duplicate a Section in the Bricks Template
Open your lesson template in Bricks Builder.
Duplicate the block where you want premium content to appear (for example: under a lesson link area), then rename it to something like:
- Premium Content
Step 3: Create Two Content Areas
Inside that Premium Content block, add two rich text elements:
- Protected Text (this is the premium content field)
- Subscribe Message (this is shown to non-members)
Step 4: Map the Premium Content Field (Dynamic Data)
Click the Protected Text element and map it to your custom field using Dynamic Data.
Example:
- Dynamic Data → ACF → Protected Text
Step 5: Add Conditions for Who Sees What
This is where the membership logic happens.
Subscribe Message should show when the user is:
- Not a SureCart customer
- Not a subscriber
Protected Content should show when the user is:
- A SureCart customer
- A subscriber
- An administrator
Once saved, you can test the result by opening the page in a different browser where you’re not logged in.
Part 2: Protect Entire Pages Using a Redirect Function
Block-level protection is perfect for most course content. But sometimes you want to protect the entire lesson page from being viewed.
For that, I use a simple custom function that checks a field called protect_page and redirects unauthorized users to a page called:
/no-access
Step 1: Create a No Access Page
Create a WordPress page titled:
- No Access
And set the slug as:
no-access
This ensures the redirect works consistently.
Step 2: Add the PHP Function to Your Child Theme
This code should be placed inside:
functions.phpof your child theme
Using a child theme matters because Bricks updates can overwrite theme files.
Function Code Used in This Lesson
Copy/paste this into your child theme functions.php (or a code snippets plugin).
Important: Copy/paste this into your child theme functions.php file (or use a code snippets plugin).
Before you paste: Most functions.php files already begin with <?php at the very top. Just confirm it’s there first (if it’s missing, add it before pasting any PHP code).
Tip: If WordPress won’t let you save PHP edits (or the Theme File Editor is disabled), you may need to paste this code using your hosting file access instead (example: cPanel File Manager, FTP, or your host’s file editor).
// Check if the current user is a SureCart customer, a WordPress subscriber, or an administrator
function bb_protect_is_active_member() {
// Allow admins always
if ( current_user_can('administrator') ) {
return true;
}
// Must be logged in for role checks
if ( ! is_user_logged_in() ) {
return false;
}
$user = wp_get_current_user();
// Define valid roles (extend anytime)
$valid_roles = array('sc_customer', 'subscriber');
// Check if user has at least one valid role
if ( ! empty($user->roles) && array_intersect($valid_roles, $user->roles) ) {
return true;
}
return false;
}
// Protect the page or post from being displayed based on 'protect_page' field value
function bb_protect_page_or_post() {
// If we can't determine post ID, bail safely
$post_id = get_the_ID();
if ( ! $post_id ) {
return;
}
// Get protect_page field (ACF first, fallback to post meta)
$protect_page = function_exists('get_field')
? get_field('protect_page', $post_id)
: get_post_meta($post_id, 'protect_page', true);
// Normalize truthy values
$is_protected = in_array($protect_page, array(1, '1', true, 'yes', 'on'), true);
// Only protect if toggle is enabled
if ( ! $is_protected ) {
return;
}
// If user is not authorized, redirect
if ( ! bb_protect_is_active_member() ) {
// Prevent redirect loops (by slug)
if ( ! is_page('no-access') ) {
wp_safe_redirect( home_url('/no-access') );
exit;
}
}
}
// Hook into template_redirect (runs before output)
add_action('template_redirect', 'bb_protect_page_or_post');
Wrapping It Up
This protection method is lightweight and flexible. You can safely restrict premium lesson content without adding a complicated membership plugin — and still allow SureCart customers and subscribers to access what they paid for.
If you want more control later, you can expand this system with additional roles, page-level rules, and course progress logic.
Lesson Overview
Main Points
√ Use custom fields to protect content
√ Create conditions based on user roles
√ Set up protected text for premium users
√ Display alternate messages for non-subscribers
√ Protect entire pages using custom functions