Every hook below is fired by the plugin in its current code. There are no REST API endpoints and no public helper functions in this plugin; extend it through these hooks.
Action hooks
Section titled “Action hooks”| Action | Arguments | Where it fires |
|---|---|---|
bplock_before_apply_protection |
$lr_form, $general_settings |
Before protection is applied to a request. |
bplock_protecting_page |
$current_url, $general_settings |
When a specific page is about to be protected (partial mode). |
bplock_before_login_form |
none | Top of the locked-content template, before the form block. |
bplock_after_login_form |
none | Bottom of the locked-content template, after the form block. |
bp_lock_after_login_form |
none | Inside the login form template, before the login button. |
Example:
add_action( 'bplock_protecting_page', function ( $current_url, $settings ) { error_log( 'Private Community protecting: ' . $current_url );}, 10, 2 );Filter hooks
Section titled “Filter hooks”| Filter | Arguments | Purpose |
|---|---|---|
bplock_protection_method |
$lr_form, $general_settings |
Change the method (plugin_form, custom_form, page_redirect) at runtime. |
bplock_redirect_url |
$redirepage_url, $redirepage |
Change the redirect destination URL. |
bplock_protected_template |
$template, $lr_form, $general_settings |
Override the template used for protected content. |
bplock_is_page_protected |
$protected, $current_url, $general_settings |
Force a page protected or public in partial mode. |
bplock_locked_urls |
$locked_urls, $current_url |
Modify the list of protected URLs (partial mode). |
bplock_whitelist_urls |
$urls, $current_url |
Modify the whitelist (full mode). Also runs when posts are checked for search, feeds, REST and sitemaps. |
bplock_restrict_feeds |
$block, $general_settings |
Whether a feed or sitemap request is blocked for visitors, including BuddyPress activity feeds. |
bplock_filter_search_results |
$enabled, $query, $general_settings |
Return false to stop removing locked posts from search, feeds, REST lists and sitemaps. |
bplock_page_template |
$template, $protected, $general_settings |
Final filter on the resolved template for a page. |
bplock_login_success_message |
$msg |
Change the login success message. |
bplock_locate_template |
$template, $template_name, $template_path, $default_path |
Change which template file is located. |
bplock_locked_content_template |
$path |
Change the locked-content template file path. |
bplock_default_locked_message |
$message |
Change the default members-only message. |
bplock_locked_template_pg_title |
$title |
Change the locked page title (default “Members Only”). |
bplock_rest_allowed_routes |
$allowed, $route, $general_settings |
REST routes (exact or prefix) that stay open to visitors while a lock is active. Default: the two jwt-auth/v1/token routes. |
bplock_restrict_rest_route |
$should_block, $route, $general_settings |
Override whether a REST route is blocked for a visitor. Full Protection blocks all routes; Partial Protection blocks buddypress/ routes and wp/v2/users. |
bplock_get_all_pages_limit |
$limit |
Pages the Add All Pages tool adds. Default 500. |
bplock_redirect_page_limit |
$limit |
Pages listed in the redirect-page picker. Default 200. |
bplock_admin_tabs |
$tabs |
Add or change admin settings tabs. |
bplock_admin_menu_capability |
'manage_options' |
Change the capability required to see the admin menu. |
Example - keep WooCommerce cart and checkout public under Full Protection:
add_filter( 'bplock_whitelist_urls', function ( $urls, $current_url ) { if ( class_exists( 'WooCommerce' ) ) { $urls[] = '/cart'; $urls[] = '/checkout'; } return $urls;}, 10, 2 );Example - protect a URL dynamically in partial mode:
add_filter( 'bplock_is_page_protected', function ( $protected, $current_url, $settings ) { if ( false !== strpos( $current_url, '/premium' ) ) { return true; } return $protected;}, 10, 3 );URL matcher class
Section titled “URL matcher class”Every allow and deny decision runs through Bp_Lock_Url_Matcher, so the whitelist and the locked list cannot disagree. Use it if you extend matching.
$candidates = Bp_Lock_Url_Matcher::candidates_for_request();$rules = Bp_Lock_Url_Matcher::split_list( $textarea_value );
if ( Bp_Lock_Url_Matcher::matches_any( $rules, $candidates ) ) { // The current request matches one of the rules.}| Method | Purpose |
|---|---|
split_list( $raw ) |
Textarea to array, dropping blanks and # comments. |
normalize( $value ) |
URL, path or slug to a comparable path. |
matches( $pattern, $candidates ) |
One rule against candidate paths. |
matches_any( $patterns, $candidates ) |
Any rule against candidate paths. |
candidates_for_post( $post_id ) |
Normalized path for a post. |
candidates_for_request() |
Normalized paths for the current request, including the resolved permalink. |
The matching rules are described in How URL rules match.

