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

Send a notification for a subscriber


Description Description


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 duplicate's 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

	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 ) ) {
			// 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 );

			}
		}

		return $id;

	}

Top ↑

Changelog Changelog

Changelog
Version Description
3.8.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

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





Permalink: