Developer reference: shortcodes, hooks, REST API and webhooks

A quick reference for developers working with Leaky Paywall. Each section links to the full article with examples.

Shortcodes

  • [leaky_paywall_login] - login form.
  • [leaky_paywall_subscription] - subscribe cards.
  • [leaky_paywall_register_form] - registration and payment form. See Create custom registration pages with shortcodes.
  • [leaky_paywall_profile] - My Account page.
  • [leaky_paywall_subscriber]...[/leaky_paywall_subscriber] - show content to active subscribers only. Add levels="1,2" to limit it to specific levels.
  • [leaky_paywall_not_subscriber]...[/leaky_paywall_not_subscriber] - show content to anyone who isn't an active subscriber. It also accepts levels="1,2", to show content to anyone who isn't subscribed to those levels. See Shortcodes to show/hide subscriber content.
  • [leaky_paywall_gift_subscriptions] - gift subscription form (Gift Subscriptions add-on). See Gift Subscriptions.

For IssueM shortcodes, see IssueM shortcodes.

Actions and filters

  • leaky_paywall_new_subscriber (action) - runs after a new subscriber is added. Use it to send the subscriber to a CRM or another system. See How to add a new user to a third party system.
  • leaky_paywall_filter_is_restricted (filter) - decide whether a post is restricted, for example to let readers from a newsletter or a referrer bypass the meter. See How to bypass the meter based on referrer URL.
  • leaky_paywall_current_user_can_view_all_content (filter) - change which user capability bypasses the paywall (default manage_options). See How to tell Leaky Paywall to ignore editors and other user roles.
  • leaky_paywall_subscribe_or_login_message and leaky_paywall_nag_message_text (filters) - change the subscribe message readers see. See How to adjust the subscribe message on a post.
  • leaky_paywall_login_form_args (filter) - change the arguments passed to the login form, for example to tick "Remember me" by default. See How to set the number of days until subscribers get logged out.
  • leaky_paywall_ip_address (filter) - change how Leaky Paywall detects the visitor's IP address, for example behind a proxy or CDN. The IP Exceptions and IP Blocker add-ons use it. See IP Exceptions.
  • manage_leaky_paywall_settings (filter) - change the capability needed to manage Leaky Paywall (default manage_options). It controls access to the Leaky Paywall admin menu, the admin REST API endpoints and the subscriber data on the WordPress users endpoint.

REST API

The REST API is on by default. You can turn it off with the WP REST API checkbox under Leaky Paywall > Settings > General.

  • Leaky Paywall API: https://your-site.com/wp-json/leaky-paywall/v1 with endpoints for /subscribers and /me. The Group Accounts add-on adds /groups. See Leaky Paywall REST API.
  • WordPress users endpoint: adds a leaky_paywall_meta object to /wp-json/wp/v2/users with level_id, subscriber_id, price, plan, created, expires, has_access, payment_gateway and payment_status. Use leaky_paywall_meta.has_access to check whether someone can read restricted content. The object is only filled in when a user requests their own record or an admin makes the request. Otherwise it is null. See How to use the WP REST API to give access.

Payment statuses

Every subscriber has a payment status that controls their access, such as active, trial, pending_cancel, past_due, canceled, expired and deactivated. deactivated is final: Leaky Paywall won't restore access automatically. See What does the Payment Status field mean? and the full list in the REST API article.

Stripe webhooks

Your Stripe webhook endpoint is https://your-site.com/?listener=stripe. Select all events when you create it in Stripe. See Stripe Payment Gateway. If you use Cloudflare, see How to allowlist Stripe's webhook IPs in Cloudflare.

Debugging

  • Turn on detailed logging under Leaky Paywall > Tools > Debug Log. Errors are always logged.
  • Add the LEAKY_PAYWALL_LOG_DIR constant to wp-config.php to store logs outside your website folder.

See The Leaky Paywall debug log.

More developer guides

Can't find the hook you need? Contact us.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us