LLMS_REST_Webhook::process_hook( mixed $args )

Processes information from the origination action hook


Description Description

Determines if the webhook should be delivered and whether or not it should be scheduled or delivered immediately.


Top ↑

Parameters Parameters

$args

(mixed) (Required) Arguments from the hook.


Top ↑

Return Return

(int|false) Timestamp of the scheduled event when the webhook is successfully scheduled. false if the webhook should not be delivered or has already been delivered in the last 5 minutes.


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/models/class-llms-rest-webhook.php

	public function process_hook( ...$args ) {

		if ( ! $this->should_deliver( $args ) ) {
			return false;
		}

		// Mark this hook's first argument as processed to ensure it doesn't get processed again within the current request,
		// as it might happen with webhooks with multiple hookes defined in `LLMS_REST_Webhooks::get_hooks()`.
		$this->processed[] = $args[0];

		/**
		 * Disable background processing of webhooks by returning a falsy
		 *
		 * Note: disabling async processing may create delays for users of your site.
		 *
		 * @param bool              $async Whether async processing is enabled or not.
		 * @param LLMS_REST_Webhook $this  Webhook object.
		 * @param array             $args  Numeric array of arguments from the originating hook.
		 */
		if ( apply_filters( 'llms_rest_webhook_deliver_async', true, $this, $args ) ) {
			return $this->schedule( $args );
		}

		return $this->deliver( $args );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.17 Mark this hook's first argument as processed to ensure it doesn't get processed again within the current request. And don't rely anymore on the webhook's pending_delivery property to achieve the same goal.
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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