How to Check if the Current User is Subscribed to Your Newsletter

When building personalized experiences or managing access to subscriber-only content, it’s essential to determine whether the currently displayed visitor is already subscribed to your newsletter.

Noptin makes this easy with the noptin_is_subscriber() function.

In this article, we’ll explore how this function works and how you can use it to enhance your WordPress website.

Function Overview

/**
 * Checks if the currently displayed user is subscribed to the newsletter.
 *
 * @since 1.4.4
 * @return bool True if the user is subscribed, false otherwise.
 */
function noptin_is_subscriber();

Example Usage

You can use this function in your theme templates, shortcodes, or plugin code to conditionally show content to newsletter subscribers:

Show a message to subscribers:

if ( noptin_is_subscriber() ) {
    echo 'Thank you for subscribing!';
}

Restrict content to subscribers:

if ( noptin_is_subscriber() ) {
    // Show exclusive content
    get_template_part( 'template-parts/content', 'subscriber' );
} else {
    // Prompt to subscribe
    echo '<p>Please subscribe to view this content.</p>';
}

Related Guides