get_current_noptin_subscriber_id()

Retrieves the current user’s Noptin subscriber id.


Return Return

(false|int) Subscriber id or false on failure.


Top ↑

Source Source

File: includes/subscriber.php

function get_current_noptin_subscriber_id() {

	// If the user is logged in, check with their email address.
	$user_data = wp_get_current_user();
	if ( ! empty( $user_data->user_email ) ) {
		$subscriber = get_noptin_subscriber_by_email( $user_data->user_email );

		if ( $subscriber->exists() ) {
			return $subscriber->id;
		}

	}

	// Check from the subscription cookies.
	if ( ! empty( $_COOKIE['noptin_email_subscribed'] ) ) {
		$subscriber = new Noptin_Subscriber( sanitize_text_field( $_COOKIE['noptin_email_subscribed'] ) );

		if ( $subscriber->exists() && sanitize_text_field( $_COOKIE['noptin_email_subscribed'] ) == $subscriber->confirm_key ) {
			return $subscriber->id;
		}

	}

	return false;
}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.5.1Introduced.

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