PaywallProject Docs
  1. Home
  2. PaywallProject plugin
  3. Check whether a reader is a subscriber from your theme or plugin
  1. Home
  2. Developer
  3. Check whether a reader is a subscriber from your theme or plugin

Check whether a reader is a subscriber from your theme or plugin

PaywallProject decides who can read a gated post on its own. Sometimes your theme or a custom plugin also needs to know whether a reader is a subscriber. For example, you might want to hide ads for paying readers, show a “Subscribe” button only to readers who aren’t subscribed yet, or add a “Subscriber” badge to the header. This article is for the developer who builds that. It needs PaywallProject 4.2.0 or later.

Check the current reader

Call ppaccess_is_active_subscriber(). It returns true when the reader who is logged in has an active subscription, and false otherwise. A reader who is logged out always gets false.

<?php if ( function_exists( 'ppaccess_is_active_subscriber' ) && ppaccess_is_active_subscriber() ) : ?>
    <span class="subscriber-badge">Subscriber</span>
<?php endif; ?>

Keep the function_exists() check. Without it, your site shows an error while PaywallProject is deactivated or being updated.

Check a specific reader

Pass a WordPress user ID as the first argument:

if ( ppaccess_is_active_subscriber( $user_id ) ) {
    // This user has an active subscription.
}

Check for specific plans

To count only some subscription levels, pass their level IDs as the second argument. Use null as the first argument to mean the current reader.

// Current reader, on level 2 or level 3 only.
if ( ppaccess_is_active_subscriber( null, array( 2, 3 ) ) ) {
    // Show the premium newsletter sign-up.
}

You can find each level’s ID in the ID column at PaywallProject → Levels.

To find out which level a reader is on, call ppaccess_get_subscriber_level_id(). It returns the level ID, or 0 when the reader has no active subscription. It also takes an optional user ID.

$level_id = ppaccess_get_subscriber_level_id();

Who counts as a subscriber

  • Active, trialing, or set to cancel: yes, until the subscription’s end date.
  • Cancelled, with paid-up time left: yes, until the date they paid up to. After that, no.
  • Past due, expired, or never subscribed: no.
  • Members of a group plan: yes, while their membership is active and the group owner’s subscription is active. They count as being on the group owner’s level.
  • Administrators and editors: no, unless they have a subscription of their own. They can read gated posts, but having access isn’t the same as subscribing.

These functions answer “is this person a subscriber?” They don’t tell you whether someone can read a particular post. A gift link, a free-registration pass, or the article meter can open a post for a reader who isn’t a subscriber.

Without code: the members-only shortcode

If you only want to show part of a page to subscribers, you can use a shortcode in the editor instead:

[ppaccess_members_only]Only subscribers see this.[/ppaccess_members_only]

[ppaccess_members_only levels="2,3"]Only subscribers on level 2 or 3 see this.[/ppaccess_members_only]

The shortcode differs from the functions in two ways. Administrators always see the content, so they can preview the page. Members of a group plan don’t see it unless they have a subscription of their own.

For developers: hooks

To change the answer, for example to count a staff role as subscribers, use the ppaccess_is_active_subscriber filter. It receives the result, the user ID, and the level IDs the caller asked about.

add_filter( 'ppaccess_is_active_subscriber', function ( $active, $user_id, $level_ids ) {
    if ( user_can( $user_id, 'edit_posts' ) ) {
        return true; // Treat your newsroom staff as subscribers.
    }
    return $active;
}, 10, 3 );

The filter changes only what ppaccess_is_active_subscriber() returns. It doesn’t change who the paywall lets in.

To run your own code whenever a reader’s subscription status changes, for example to update another system, use the ppaccess_subscriber_status_changed action. It receives the user ID, the new status, the old status, and where the change came from.

Good to know

  • The check is fast. It reads the subscription details saved on your site and never calls Stripe.
  • Call these functions in templates or on the init hook or later, not straight from a plugin file as it loads.
  • Full-page caching can show one reader’s version of a page to everyone. If you change what a page shows based on these functions, make sure your cache doesn’t serve cached pages to logged-in readers. Most WordPress caches skip logged-in readers by default.
Updated on November 9, 2026
Was this article helpful?

Related Articles

Get more help
Can't find the answer you're looking for? Get in touch.
Contact support