LLMS_Engagements::maybe_trigger_engagement()
Handles all actions that could potentially trigger an engagement
Description Description
It will fire or schedule the actions after gathering all necessary data.
Return Return
(void)
Source Source
File: includes/class.llms.engagements.php
public function maybe_trigger_engagement() {
// Parse incoming hook data.
$hook = $this->parse_hook( current_filter(), func_get_args() );
// We need a user and a trigger to proceed, related_post is optional though.
if ( ! $hook['user_id'] || ! $hook['trigger_type'] ) {
return;
}
// Gather triggerable engagements matching the supplied criteria.
$engagements = $this->get_engagements( $hook['trigger_type'], $hook['related_post_id'] );
// Loop through the retrieved engagements and trigger them.
foreach ( $engagements as $engagement ) {
$handler = $this->parse_engagement( $engagement, $hook );
$this->trigger_engagement( $handler, $engagement->delay );
}
}
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
| Version | Description |
|---|---|
| 6.0.0 | Major refactor to reduce code complexity. |
| 3.39.0 | Treat also llms_rest_student_registered action. |
| 3.11.0 | Unknown. |
| 2.3.0 | Introduced. |