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::trigger_engagement( array $data, int $delay )

Triggers or schedules an engagement


Parameters Parameters

$data

(array) (Required) Handler data from parse_engagement().

$delay

(int) (Required) The engagement send delay (in days).


Top ↑

Return Return

(void)


Top ↑

Source Source

File: includes/class.llms.engagements.php

	private function trigger_engagement( $data, $delay ) {

		// Can't proceed without an action and a handler.
		if ( empty( $data['handler_action'] ) || empty( $data['handler_args'] ) ) {
			return;
		}

		// If we have a delay, schedule the engagement handler.
		$delay = absint( $delay );
		if ( $delay ) {

			as_schedule_single_action(
				time() + ( DAY_IN_SECONDS * $delay ),
				$data['handler_action'],
				array( $data['handler_args'] ),
				! empty( $data['handler_args'][3] ) ? $this->get_delayed_group_id( $data['handler_args'][3] ) : null
			);

		} else {

			/**
			 * Skip processing checks for immediate engagements.
			 *
			 * We know the user exists (because they're currently logged in) and we don't have to run
			 * publish/existence checks on all the related posts because the `get_engagement()` query takes care
			 * of that already.
			 */
			add_filter( 'llms_skip_engagement_processing_checks', '__return_true' );

			do_action( $data['handler_action'], $data['handler_args'] );

			remove_filter( 'llms_skip_engagement_processing_checks', '__return_true' );

		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.