Noptin_Subscriber::__construct( int|string|array|stdClass|Noptin_Subscriber $subscriber )

Constructor.


Description Description

Inits the subscriber data.


Top ↑

Parameters Parameters

$subscriber

(int|string|array|stdClass|Noptin_Subscriber) (Required) Subscribers's ID, email, confirm key, a Noptin_Subscriber object, or a subscriber object from the DB.


Top ↑

Source Source

File: includes/class-noptin-subscriber.php

	public function __construct( $subscriber = 0 ) {

		// $subscriber can be...
		// ... an instance of this class...
		if ( $subscriber instanceof Noptin_Subscriber ) {
			$this->init( $subscriber->to_array() );
			return;
		}

		// ... a row from the database...
		if ( is_object( $subscriber ) || is_array( $subscriber ) ) {
			$this->init( $subscriber );
			return;
		}

		if ( empty( $subscriber ) ) {
			$this->data = new stdClass;
			return;
		}

		// ... the subscriber's id...
		if ( is_numeric( $subscriber ) ) {

			$data = self::get_data_by( 'id', $subscriber );

			// ... the subscriber's email...
		} elseif( is_email( $subscriber ) ) {

			$data = self::get_data_by( 'email', $subscriber );

			// ... or the subscriber's confirm key.
		} elseif( is_string( $subscriber ) ) {

			$data = self::get_data_by( 'confirm_key', $subscriber );

		}

		if ( empty( $data ) ) {
			$this->data = new stdClass;
		} else {
			$this->init( $data );
		}

	}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.2.7Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation