The Action Triggers module lets BricksMembers react to arbitrary WordPress action hooks and turn those events into level assignments, enrollments, or group membership changes. In the current codebase, the runtime owner is src/Modules/ActionTriggers/ActionTriggersSystem.php and the canonical settings write owner is src/Services/ActionTriggersService.php.
Module Gate and Entry Points
- Module flag:
brm_enable_action_triggers - Bootstrap path:
src/Bootstrap/BootstrapCoordinator.php→ActionTriggersSystem::boot() - Admin surface:
admin.php?page=brm_integrations&tab=action-triggers - AJAX adapter:
src/Ajax/ActionTriggersActions.php
Stored Trigger Shape
Triggers are stored in the brm_action_triggers option and normalized through ActionTriggersService. The normalized row keeps:
uuidhook_nameaction_type=level,post_enrollment, orgroup_membershipaction=add,remove,enroll, orcanceldepending on typelevel_id,post_id, orgroup_iddepending on typegroup_rolefor group membership triggersuse_current_userpriorityenabled
Runtime Binding
ActionTriggersSystem registers active triggers on init. Each enabled row creates a runtime add_action() binding for the configured hook name and priority. Invalid hook names are skipped after sanitization.
use BaselMedia\BricksMembers\Core\ModuleRegistry;
use BaselMedia\BricksMembers\Modules\ActionTriggers\ActionTriggersSystem;
if ( ModuleRegistry::is_active( 'action_triggers' ) ) {
ActionTriggersSystem::boot();
}
User Resolution
The runtime can either use the current logged-in user or auto-detect a user from hook arguments. The detection path accepts numeric IDs, WP_User-like objects, objects with an ID field, values with a get_user_id() method, login strings, and arrays with a user_id key.
Supported Mutation Types
- Level actions: add or remove a BRM level for the resolved user
- Post enrollment actions: enroll or cancel enrollment for one configured post
- Group membership actions: add or remove the user from a configured group and role
Admin AJAX Surface
The admin UI persists triggers through these AJAX actions:
brm_add_action_triggerbrm_edit_action_triggerbrm_delete_action_triggerbrm_toggle_action_triggerbrm_get_action_trigger
ActionTriggersActions stays thin. It validates the request and delegates normalization and persistence to ActionTriggersService.
Edit Guidance
- Start in
ActionTriggersServicewhen you need to change stored trigger shape. - Start in
ActionTriggersSystemwhen you need to change runtime binding or user extraction. - Start in
ActionTriggersActionsonly when the admin transport needs to change.