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.

Working with Data in BricksMembers

Working with Data in BricksMembers
Pascal Basel
modified at December 8, 2025

BricksMembers stores data using an optimized architecture. You don’t need to know the internal structure to use the API, but understanding data concepts helps when extending the plugin.

Data Concepts

User Data

User data includes levels, completion tracking, and progress. Access user data through the API functions:

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

// Get user's completed content
$completed = brm_core()->get_user_completed_posts( $user_id );

// Get user data object
$user_data = brm_core()->get_user_data( $user_id );

Post Data

Post data includes access rules, structure relationships, and protection settings:

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

// Get required levels for post
$required_levels = brm_get_post_required_levels( $post_id );

// Get full post data object
$post_data = brm_core()->get_post_data( $post_id );

Levels

Levels are membership tiers defined in the system. Access level information through the API:

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

// Get specific level
$level = brm_get_level_by_id( $level_id );

// Get level information
$level = brm_get_level_by_id( $level_id );

Progress Data

Progress is aggregated at different scopes (structure or taxonomy). Access progress through dedicated functions:

// Check if content is completed
$is_completed = brm_is_content_completed( $user_id, $post_id );

// Get completion date
$date = brm_get_completion_date( $user_id, $post_id );

// Get progress percentage (if module enabled)
if ( brm_get_module_config()['progress_tracking'] ) {
    // Progress tracking functions available
}

Updating Data

Always use API functions to modify data. They handle cache invalidation, validation, and trigger appropriate hooks:

// Update user levels
brm_core()->add_user_level( $user_id, $level_id );
brm_core()->remove_user_level( $user_id, $level_id );

// Update post protection
brm_set_post_levels( $post_id, [1, 2, 3] );

// Update completion status
brm_mark_content_completed( $user_id, $post_id );

// Update post data directly (advanced)
brm_update_post_data( $post_id, [
    'required_levels' => [1, 2]
] );

Data Caching

BricksMembers caches data automatically for performance. When you update data through API functions, caches are cleared automatically. You rarely need to manage cache manually:

// Cache is managed automatically
// When you call:
brm_core()->add_user_level( $user_id, $level_id );

// Cache is automatically cleared for:
// - User levels
// - User data
// - Related access checks

Best Practices

  • Use API functions: Always use brm_* functions to read/write data
  • Don’t access database directly: Internal structure may change; API functions are stable
  • Use filters to modify: Filter data rather than modifying stored values when possible
  • Trust cache management: API functions handle cache invalidation automatically
  • Hook into actions: Use actions to react to data changes rather than polling

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!