Protected Downloads Runtime and API

The Protected Downloads module combines a dedicated download post type, access-checked delivery, optional provider-backed remote files, and assigned-download reads for Bricks layouts. The canonical runtime owner is src/Modules/Downloads/DownloadSystem.php.

Module Gate and Entry Points

  • Module flag: brm_enable_protected_downloads
  • Bootstrap path: src/Bootstrap/BootstrapCoordinator.phpDownloadSystem::boot()
  • Admin page: admin.php?page=brm-downloads
  • Bricks element: src/Elements/ProtectedDownloadElement.php
  • Assignment owner: src/Modules/Downloads/DownloadAssignmentService.php

Core Runtime Responsibilities

  • register the brm_download post type
  • add rewrite rules and handle secure download requests
  • boot provider support and the remote file browser
  • register meta boxes and save download metadata
  • serve either local protected files or signed remote URLs
  • create the optional download logs table

Provider Architecture

Remote providers register through src/Modules/Downloads/Providers/ProviderRegistry.php. The current provider set includes Local, S3, Bunny, and GCS adapters. For remote downloads, DownloadSystem asks the active provider for a short-lived signed URL and redirects the browser there after access checks pass.

Assigned Downloads

DownloadAssignmentService owns the relation between content posts and download posts. That is the canonical write and read owner for “downloads assigned to the current post” behavior used by Bricks elements, query filters, meta boxes, and structure quick edit flows.

Secure Delivery Flow

  1. resolve the requested download
  2. require a logged-in user for protected delivery
  3. check access through the BRM download access helper
  4. log the download when logging is enabled
  5. serve the local file or redirect to a provider-signed URL

Admin Surfaces

  • src/Admin/DownloadsAdmin.php
  • src/Admin/DownloadsAdminHandlers.php
  • src/Admin/DownloadsAdminRender.php

These classes own the admin UI transport. They do not become alternate owners for runtime access rules or provider delivery.

Edit Guidance

  • Start in DownloadSystem for runtime delivery, CPT wiring, or provider boot.
  • Start in DownloadAssignmentService for assignment persistence and current-post reads.
  • Start in the provider adapter when the change is provider-specific.
Early Bird Deal

Start Building Your Membership Site Today

Create, sell, and manage your content without limits. BricksMembers gives you everything you need to build membership and LMS sites with Bricks Builder.

Lifetime updates & bug fixes • Premium support • 0% transaction fees • 60-day money-back guarantee