LLMS_Abstract_Notification_Controller::send_one( string $type, mixed $subscriber, bool $force = false )

Send a notification for a subscriber


Parameters Parameters

$type

(string) (Required) Notification type id.

$subscriber

(mixed) (Required) WP User ID for the subscriber, email address, phone number, etc...

$force

(bool) (Optional) If true, will force a send even if duplicates. Default is false. Only applies to controllers that flag $this->auto_dupcheck to true.

Default value: false


Top ↑

Return Return

(int|false)


Top ↑

Source Source

File: includes/abstracts/llms.abstract.notification.controller.php

	 *                           Only applies to controllers that flag $this->auto_dupcheck to true.
	 * @return int|false
	 */
	protected function send_one( $type, $subscriber, $force = false ) {

		/**
		 * If autodupcheck is set
		 * and the send function doesn't override the dupcheck
		 * and the subscriber has already received the notification
		 * skip it.
		 */
		if ( $this->auto_dupcheck && ! $force && $this->has_subscriber_received( $type, $subscriber ) ) {
			// phpcs:ignore -- commented out code
			// llms_log( sprintf( 'Skipped %1$s to subscriber "%2$s" bc of dupcheck', $type, $subscriber ), 'notifications' );
			return false;
		}

		$notification = new LLMS_Notification();
		$id           = $notification->create(
			array(
				'post_id'    => $this->post_id,
				'subscriber' => $subscriber,
				'type'       => $type,
				'trigger_id' => $this->id,
				'user_id'    => $this->user_id,
			)
		);

		// If successful, push to the processor where processing is supported.
		if ( $id ) {

			$processor = llms()->notifications()->get_processor( $type );
			if ( $processor ) {

				$processor->log( sprintf( 'Queuing %1$s notification ID #%2$d', $type, $id ) );
				$processor->push_to_queue( $id );
				llms()->notifications()->schedule_processing( $type );

			}
		}



Top ↑

Changelog Changelog

Changelog
Version Description
3.8.0
3.24.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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