Skip to content

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 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.
bp_lock_after_register_form none Inside the register form template, after the fields.

Example:

add_action( 'bplock_protecting_page', function ( $current_url, $settings ) {
error_log( 'Private Community protecting: ' . $current_url );
}, 10, 2 );
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).
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_register_success_message $msg Change the registration 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_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 );