We built DEV3 AI Membership & Paywall as a WordPress plugin in PHP with a React admin, Gutenberg blocks and shortcodes for every member screen. The AI runs on the Google Gemini API with the site owner's own key.
Key design decisions
- One access decision.
Engine::check() answers "can this user read this post right now?" from the post's own setting plus every matching rule (post type, picked items, terms with their children), with drip by days or date, bypass for admins and editors, and a reason code for every answer. It is memoised per request and filterable.
- Enforced at every exit.
the_content, feeds, REST responses for every public post type, archives and search, blocks, menu items, the [dev3mb_restrict] shortcode, WooCommerce purchasability and protected file downloads all call the same engine.
- Access filtering before the prompt. The member Q&A assistant retrieves passages by embeddings, then drops every passage from an article the asker cannot open before the prompt is built. The visitor is told how many members-only articles matched and offered the plans.
- Explainable churn. A 0–100 score per membership from logins, reading drop-off, failed payments, cancellation and tenure, with each point named. The AI only drafts the win-back email.
- Drafts, never auto-actions. The tier designer, smart teasers, win-back emails and onboarding sequences all return drafts the owner accepts, edits or rejects.
- Three ways to pay. Stripe Checkout with signed webhooks (300-second tolerance, constant-time compare), PayPal Checkout and Subscriptions with verified webhooks, and the WooCommerce checkout with Subscriptions renewals synced. Keys are encrypted at rest.
Architecture
Levels, rules, memberships, payments, coupons and activity live in custom tables. An hourly job expires memberships, marks missed renewals past due, sends reminders and runs welcome sequences. Protected files move to a private folder and download through a checked link. The API client, encryption, background jobs, embeddings store and settings screens come from a shared core used across DEV3's plugins.