noptin_is_subscriber()

Checks if the currently displayed user is subscribed to the newsletter.


Return Return

(bool)


Top ↑

Source Source

File: includes/subscriber.php

function noptin_is_subscriber() {

	// If the user is logged in, check with their email address and ensure they are active.
	$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 empty( $subscriber->active );
		}

	}

	// Check from the login cookies.
	if ( ! empty( $_COOKIE['noptin_email_subscribed'] ) ) {
		return true;
	}

	$cookie = get_noptin_option( 'subscribers_cookie' );
	if ( ! empty( $cookie ) && is_string( $cookie ) && ! empty( $_COOKIE[ $cookie ] ) ) {
		return true;
	}

	return false;

}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.4.4Introduced.

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