LLMS_Notification::create( array $data = array() )

Create a new notification in the database


Parameters Parameters

$data

(array) (Optional) notification data

Default value: array()


Top ↑

Return Return

(int|false) new notification id on success, false otherwise


Top ↑

Source Source

File: includes/models/model.llms.notification.php

	public function create( $data = array() ) {

		$time = current_time( 'mysql' );

		$data = wp_parse_args(
			$data,
			array(

				'created'    => $time,
				'post_id'    => null,
				'status'     => 'new',
				'subscriber' => null,
				'trigger_id' => null,
				'type'       => '',
				'updated'    => $time,
				'user_id'    => null,

			)
		);

		ksort( $data ); // Maintain alpha sort you savages.

		$format = array(
			'%s', // For created.
			'%d', // For post_id.
			'%s', // For status.
			'%s', // For subscriber.
			'%s', // For trigger_id.
			'%s', // For type.
			'%s', // For updated.
			'%d', // For user_id.
		);

		global $wpdb;

		if ( 1 !== $wpdb->insert( $this->get_table(), $data, $format ) ) {
			return false;
		}

		$this->id = $wpdb->insert_id;

		return $this->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.