LLMS_REST_Webhook_Data::set_delivery_failure()

Increment delivery failures and after max allowed failures are reached, set status to disabled.


Return Return

(LLMS_REST_Webhook)


Top ↑

Source Source

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

	protected function set_delivery_failure() {

		$failures = absint( $this->get( 'failure_count' ) );

		$this->set( 'failure_count', ++$failures );

		/**
		 * Filter the number of times a webhook is allowed to fail before it is automatically disabled.
		 *
		 * @since 1.0.0-beta.1
		 *
		 * @param int $num Number of allowed failures. Default: 5.
		 */
		$max_allowed = apply_filters( 'llms_rest_webhook_max_delivery_failures', 5 );

		if ( $failures > $max_allowed ) {

			$this->set( 'status', 'disabled' );

			/**
			 * Fires immediately after a webhook has been disabled due to exceeding its maximum allowed failures.
			 *
			 * @since 1.0.0-beta.1
			 *
			 * @param int $webhook_id ID of the webhook.
			 */
			do_action( 'llms_rest_webhook_disabled_by_delivery_failures', $this->get( 'id' ) );

		}

		return $this;

	}


Top ↑

Changelog Changelog

Changelog
Version Description
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.