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.

BricksMembers API Reference

BricksMembers API Reference
Pascal Basel
modified at February 9, 2026

BricksMembers API Reference

Quick reference for the public functions, actions, and filters exposed by BricksMembers. All entries below map directly to functions and hooks implemented in the plugin.

Core Instances

// Core singletons
$core   = brm_core();   // BRM_Core
$helper = brm_helper(); // BRM_Core_Helper

// Initialize system (normally automatic)
brm_initialize_core_system();

User Levels API

// Read levels
$all_levels  = brm_get_all_levels();
$level       = brm_get_level_by_id( $level_id );
$user_levels = brm_core()->get_user_levels( $user_id );

// Manage levels
$level_id = brm_create_level( 'Premium', 'Premium membership' );
brm_update_level( $level_id, ['name' => 'VIP'] );
brm_delete_level( $level_id );

// Assign to users (brm_add_user_level/brm_remove_user_level preferred; wrap with brm_with_event_context in integrations)
brm_add_user_level( $user_id, $level_id );
brm_remove_user_level( $user_id, $level_id );
brm_core()->set_user_levels( $user_id, [1, 2, 3] );
brm_user_has_level( $user_id, $level_id );

Content Access & Protection

// Access checks
$has_access = brm_user_can_access_content( $user_id, $post_id );
$protection = brm_get_content_protection( $post_id );

// Post/term protection
$required = brm_get_post_required_levels( $post_id );
brm_add_post_level( $post_id, $level_id );
brm_remove_post_level( $post_id, $level_id );
brm_set_post_levels( $post_id, [1, 2] );

$term_levels = brm_get_term_required_levels( $term_id );
brm_set_term_levels( $term_id, [1, 2] );

Progress Tracking

// Completion
brm_mark_content_completed( $user_id, $post_id );
brm_mark_content_incomplete( $user_id, $post_id );
$is_completed = brm_is_content_completed( $user_id, $post_id );
$date         = brm_get_completion_date( $user_id, $post_id );

// Progress data
$completed_posts   = brm_core()->get_user_completed_posts( $user_id );
$completed_parents = brm_core()->get_user_completed_parents( $user_id );
brm_reset_user_progress( $user_id, $post_id );

Structures & Navigation

// Navigation within structures (returns WP_Post objects or null)
$next_post = brm_get_next_structure_item( $post_id, $boundary );
$prev_post = brm_get_previous_structure_item( $post_id, $boundary );
$position = brm_get_structure_current_position( $post_id, $target_level );
// Position returns: ['current_level' => int, 'order_position' => int, 'structure_id' => string]

// Boundary ancestor (e.g. course/module for current post)
$course_id = brm_get_boundary( $post_id, 'course' );
$order     = brm_get_boundary_order( $post_id, 'lesson' );

// Structure data
$structures = brm_get_all_structures();
$structure  = brm_get_structure_by_id( $structure_id );
$levels     = brm_get_structure_levels( $structure_id, 'auto' );


// Structure helpers
$structure_id = brm_get_structure_id_by_object( 'course', 'post_type' );
$level_index = brm_get_object_level_index( 'lesson', 'post_type', $structure_id );

Data Helpers

// Post data row (cached)
$post_data = brm_core()->get_post_data( $post_id );
brm_update_post_data( $post_id, ['required_levels' => [1,2]] );

// User data row (cached)
$user_data = brm_core()->get_user_data( $user_id );

Module Configuration

$config = \BaselMedia\BricksMembers\Utilities\ModuleConfig::getModuleConfig( false );
if ( $config['progress_tracking'] ) {
    // Progress functions available
}
if ( $config['drip_system'] ) {
    // Drip functions available
}
if ( $config['protected_downloads'] ) {
    // Protected downloads enabled
}

Drip Content (Optional Module)

Drip content functions are available when the drip system module is enabled:

// Check if drip is enabled
$config = \BaselMedia\BricksMembers\Utilities\ModuleConfig::getModuleConfig( false );
if ( $config['drip_system'] ) {
    // Check unlock status
    $is_unlocked = brm_drip_is_unlocked( $user_id, $post_id );
    
    // Get full drip status
    $status = brm_drip_service_get_status( $user_id, $post_id );
    // Returns: ['available' => bool, 'unlocked' => bool, 'unlock_date' => int, 'days_left' => int, ...]
    
    // Check time/prerequisite readiness
    $time_ready = brm_drip_is_time_ready( $user_id, $post_id );
    $prereq_ready = brm_drip_is_prereq_ready( $user_id, $post_id );
}

Protected Downloads (Optional Module)

Protected download functions are available when the protected downloads module is enabled:

// Check if protected downloads is enabled
$config = \BaselMedia\BricksMembers\Utilities\ModuleConfig::getModuleConfig( false );
if ( $config['protected_downloads'] ) {
    // Check if current user can access download
    $can_access = brm_can_user_access_download( $download_id );
    
    // Check access for specific user (for dynamic tags)
    $can_access = brm_can_user_access_download_hybrid( $download_id, $user_id );
}

Profile Page Detection (Member Profiles Module)

When the Member Profiles module is enabled, ProfilePageService provides user context resolution for dynamic tags:

use BaselMedia\BricksMembers\Services\ProfilePageService;

// Resolve user ID using the configured detection cascade
$user_id = ProfilePageService::get_instance()->resolve_user_id();

// Check if a specific detection method is enabled
$has_url_param = ProfilePageService::get_instance()->detection_includes( 'url_param' );
$has_author    = ProfilePageService::get_instance()->detection_includes( 'author' );

// brm_get_tag_user_id() — used by all {brm_user:*} dynamic tags
// Priority: Bricks loop user → ProfilePageService::resolve_user_id()
//   (which checks: author archive → URL param/clean URL → current user)
$tag_user_id = brm_get_tag_user_id();

// Options
get_option( 'brm_profile_user_detection', 'url_param_author' ); // current|url_param|author|url_param_author
get_option( 'brm_profile_url_param', 'user' ); // GET parameter name

// Clean URL patterns (registered when url_param mode is active)
// /member/{username}/ → query var brm_profile_user
// /profile/{user_id}/ → query var brm_profile_user_id

Recompute & Batch Processing

// Unified recompute (SPM, Progress, Drip)
brm_schedule_unified_recompute( [
    'structures' => ['courses'], // or null for all
    'spm'        => true,
    'progress'   => true,
    'drip'       => true,
] );

Note: this function delegates orchestration to the drip orchestration service to keep scheduling centralized and predictable.

Webhooks

// Endpoint
POST /wp-json/bricksmembers/v1/webhook

// Auth: secret query param, HMAC signature header, or Authorization: Bearer {brm_api_key}

// Send a test webhook (admin utility)
brm_send_test_webhook( [ [ 'key' => 'event', 'value' => 'user_level_added' ] ] );

Structured Events (v0.9.6+)

For new integrations, use the structured event system with rich payloads:

use BaselMedia\BricksMembers\Utilities\ExtensionRegistry;
use BaselMedia\BricksMembers\Core\Event;

ExtensionRegistry::subscribe(
    Event::ACCESS_GRANTED,
    function( Event $event ): void {
        $user_id  = $event->get_user_id();
        $level_id = $event->get_resource_id();
        $trigger  = $event->get_trigger();  // admin, webhook, woocommerce, cron, api
        $reason   = $event->get_reason();
        $corr_id  = $event->get_correlation_id(); // For tracing
        
        // Process event...
    }
);

// Available event types: Event::ACCESS_GRANTED, ACCESS_REVOKED, ACCESS_SCHEDULED,
// ACCESS_EXPIRED, ACCESS_REBUILT, PROGRESS_COMPLETED,
// PROGRESS_INCOMPLETED, CONTENT_UNLOCKED

WordPress Filters

Selected filters exposed by the plugin:

// Redirect behavior for protected content
add_filter( 'brm_should_apply_redirect', function( $should_redirect, $post_id, $user_id ) {
    return $should_redirect;
}, 10, 3 );

// Batch size for user backfill worker
add_filter( 'brm_unlocks_user_worker_posts_per_page', function( $posts_per_page ) {
    return 150;
} );

// Bricks integration hooks
add_filter( 'bricks/posts/query_vars', function( $query_vars, $settings, $element_id ) {
    return $query_vars;
}, 20, 3 );

add_filter( 'bricks/conditions/result', function( $result, $condition, $element_id ) {
    return $result;
}, 10, 3 );

Additional Utility Functions

// Get posts requiring a specific level
$result = brm_get_posts_requiring_level( $level_id, $page = 1, $per_page = 50 );
// Returns: ['posts' => array, 'total' => int, 'pages' => int]

// Get level user count
$count = brm_get_level_user_count( $level_id );

// Get users with a level
$user_ids = brm_get_level_users( $level_id );

// Get paginated users for a level
$result = brm_get_users_for_level_paginated( $level_id, $page = 1, $per_page = 50 );

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!