Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Engagements::parse_hook( string $action, array $args )
Parse incoming hook / callback data to determine if an engagement should be triggered from a given hook.
Parameters Parameters
- $action
-
(string) (Required) Action hook name.
- $args
-
(array) (Required) Array of arguments passed to the callback function.
Return Return
(array) An associative array of parsed data used to trigger the engagement.
- 'trigger_type'
(string) The name of the engagement trigger. Seellms_get_engagement_triggers()
for a list of valid triggers. - 'user_id'
(int) The WP_User ID of the user who the engagement is being awarded or sent to. - 'related_post_id'
(int) The WP_Post ID of a related post.
Source Source
File: includes/class.llms.engagements.php
private function parse_hook( $action, $args ) { $parsed = array( 'trigger_type' => null, 'user_id' => null, 'related_post_id' => null, ); /** * Allows 3rd parties to hook into the core engagement system by parsing data passed to the hook. * * @since 2.3.0 * * @param array $parsed { * An associative array of parsed data used to trigger the engagement. * * @type string $trigger_type (Required) The name of the engagement trigger. See `llms_get_engagement_triggers()` for a list of valid triggers. * @type int $user_id (Required) The WP_User ID of the user who the engagement is being awarded or sent to. * @type int $related_post_id (Optional) The WP_Post ID of a related post. * } * @param string $action The name of the hook which triggered the engagement. * @param array $args The original arguments provided by the triggering hook. */ $filtered_parsed = apply_filters( 'lifterlms_external_engagement_query_arguments', $parsed, $action, $args ); // If valid, return the filtered parsed data. if ( isset( $filtered_parsed['trigger_type'] ) && isset( $filtered_parsed['user_id'] ) ) { return $filtered_parsed; } // Verify that the action is a supported hook. if ( ! in_array( $action, $this->get_trigger_hooks(), true ) ) { return $parsed; } // The user registration action doesn't have a related post id. $related_post_id = isset( $args[1] ) && is_numeric( $args[1] ) ? absint( $args[1] ) : ''; $parsed['user_id'] = absint( $args[0] ); $parsed['trigger_type'] = $this->parse_hook_find_trigger_type( $action, $related_post_id ); $parsed['related_post_id'] = $related_post_id; return $parsed; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
6.6.0 | Fixed an issue where the lifterlms_external_engagement_query_arguments filter would not trigger if a 3rd party registered a trigger hook. |
6.0.0 | Introduced. |