Guides

BricksMembers Documentation

Find everything you need to set up, customize, and get the most out of BricksMembers — from quick-start guides to advanced features.

Getting Started with BricksMembers API

Getting Started with BricksMembers API
Pascal Basel
modified at February 9, 2026

Getting Started with BricksMembers API

BricksMembers provides a comprehensive API for extending and customizing the plugin. This guide introduces the core concepts and APIs you’ll use to build custom integrations.

Core API Functions

BricksMembers exposes all functionality through public functions prefixed with brm_. These functions provide safe, consistent access to plugin features.

// Access core functionality
$core = brm_core();
$helper = brm_helper();

// Get user levels
$levels = brm_core()->get_user_levels( $user_id );

// Check content access
$has_access = brm_user_can_access_content( $user_id, $post_id );

// Manage progress
brm_mark_content_completed( $user_id, $post_id );
$is_completed = brm_is_content_completed( $user_id, $post_id );

Key Concepts

User Levels

Levels are membership tiers that control content access. Users can have multiple levels, and content can require one or more levels.

// Get all levels
$all_levels = brm_get_all_levels();

// Get user's levels
$user_levels = brm_core()->get_user_levels( $user_id );

// Add/remove levels (prefer brm_add_user_level/brm_remove_user_level for integrations)
brm_add_user_level( $user_id, $level_id );
brm_remove_user_level( $user_id, $level_id );

// Set all levels at once
brm_core()->set_user_levels( $user_id, [1, 2, 3] );

Content Access

Content can be protected by requiring specific levels. The access system checks if users have the required levels before allowing access.

// Check if user can access content
$has_access = brm_user_can_access_content( $user_id, $post_id );

// Get content protection settings
$protection = brm_get_content_protection( $post_id );

// Set required levels for content
brm_set_post_levels( $post_id, [1, 2] );
brm_add_post_level( $post_id, $level_id );
brm_remove_post_level( $post_id, $level_id );

Progress Tracking

BricksMembers tracks user progress through content. Completion status is stored per user and can be queried or modified via the API.

// Mark content as completed/incomplete
brm_mark_content_completed( $user_id, $post_id );
brm_mark_content_incomplete( $user_id, $post_id );

// Check completion status
$is_completed = brm_is_content_completed( $user_id, $post_id );
$completion_date = brm_get_completion_date( $user_id, $post_id );

// Get all completed content
$completed = brm_core()->get_user_completed_posts( $user_id );

Structure Navigation

Structures organize content hierarchically (e.g., Course → Module → Lesson). The API provides navigation functions to move between items.

// Get next/previous item in structure (returns WP_Post objects or null)
$next_post = brm_get_next_structure_item( $post_id );
$next_post_id = $next_post ? $next_post->ID : null;

$prev_post = brm_get_previous_structure_item( $post_id );
$prev_post_id = $prev_post ? $prev_post->ID : null;

// Get current position in structure
$position = brm_get_structure_current_position( $post_id );
// Returns: ['current_level' => int, 'order_position' => int, 'structure_id' => string]

// Navigation with boundaries
$next = brm_get_next_structure_item( $post_id, 'toplevel' );
$prev = brm_get_previous_structure_item( $post_id, 'parentlevel' );

Extensibility Points

BricksMembers uses WordPress actions for extensibility. You can hook into events without editing plugin files.

Actions

Actions fire when events occur, allowing you to execute custom code:

// When level is added to user
add_action( 'brm_user_level_added', function( $user_id, $level_id ) {
    // Your custom code here
}, 10, 2 );

// When content is completed
add_action( 'brm_post_completed', function( $user_id, $post_id ) {
    // Your custom code here
}, 10, 2 );

Filters

The core API does not expose filters for user levels or access checks. Use the provided actions and public functions instead.

Optional Modules

Some features are optional modules that can be enabled or disabled. Check if a module is active before using its functions:

// Check module status (use ModuleConfig PSR-4 class)
$config = \BaselMedia\BricksMembers\Utilities\ModuleConfig::getModuleConfig( false );

if ( $config['progress_tracking'] ) {
    // Progress tracking is enabled
}

if ( $config['drip_system'] ) {
    // Drip content is enabled
}

if ( $config['protected_downloads'] ) {
    // Protected downloads are enabled
}

// Drip content functions (if enabled)
if ( $config['drip_system'] ) {
    $is_unlocked = brm_drip_is_unlocked( $user_id, $post_id );
    $status = brm_drip_service_get_status( $user_id, $post_id );
}

// Protected downloads functions (if enabled)
if ( $config['protected_downloads'] ) {
    $can_access = brm_can_user_access_download( $download_id );
}

// Member profiles: profile page user detection (if enabled)
if ( $config['member_profiles'] ) {
    use BaselMedia\BricksMembers\Services\ProfilePageService;
    // Resolve which user {brm_user:*} tags should display
    $user_id = ProfilePageService::get_instance()->resolve_user_id();
    // Detection cascade: Bricks loop → author archive → URL param → current user
}

Best Practices

  • Use public functions: Always use brm_* functions rather than accessing internal classes directly
  • Check dependencies: Functions return safe defaults if dependencies aren’t available
  • Hook into events: Use actions and filters rather than modifying plugin files
  • Check module status: Verify modules are enabled before using module-specific functions
  • Follow WordPress standards: All functions follow WordPress coding conventions and security practices

Create

Start Building with BricksMembers

Create, sell, and manage your content without limits. BricksMembers gives you everything you need to build membership and LMS sites directly in Bricks Builder — fast and frustration-free.

Join the membership & LMS revolution now!

Get Started
Still have questions? We're here to help!