> Sell MemberPress memberships through a Plandalf checkout with the Plandalf for MemberPress plugin. Plandalf takes the payment; MemberPress keeps access.

Source: https://plandalf.com/docs/websites/memberpress

Websites and builders

# MemberPress

The Plandalf for MemberPress plugin puts your Plandalf checkout where the MemberPress signup form was. Buyers pay through Plandalf, and the plugin gives them the membership once Plandalf confirms the payment. MemberPress keeps your members, rules and protected content.

**Early access**

These steps are for version 0.2.1 of the plugin. Set it up on a staging site first, and keep your MemberPress signup form live until a test purchase works end to end. The plugin is open source and isn't an official MemberPress product.

## Before you start

-   WordPress 6.4 or later on PHP 8.2 or later, with MemberPress installed and active.
-   A site on HTTPS that Plandalf can reach, so it can send purchase events.
-   Stripe connected in Plandalf under **Settings → Payments & Tax Integrations**. For staging, connect a Stripe test account too. You never enter Stripe keys in WordPress.
-   A published Plandalf checkout to use as the design. Keep it to the pages before payment: the plugin moves buyers on as soon as they've paid, so pages after payment, such as an upsell, don't show.
-   Email that works from WordPress. New members get their set-password link by email.

## Install the plugin and connect

1.  ### Upload the plugin
    
    Download `plandalf-memberpress.zip` from the [0.2.1 release](https://github.com/plandalf/memberpress/releases/tag/v0.2.1). Use that file, not GitHub's source code archive. In WordPress, go to **Plugins → Add Plugin → Upload Plugin**, choose the zip, click **Install Now** and then **Activate**.
    
2.  ### Connect with Plandalf
    
    Open **MemberPress → Plandalf** and click **Connect with Plandalf**. Sign in to Plandalf if it asks.
    
3.  ### Pick the account and mode
    
    Choose your Plandalf account and, under **Purchases this site receives**, pick **Test** for a staging site or **Live** for your real store. Approve the connection.
    
4.  ### Back in WordPress
    
    The plugin says **Connected to Plandalf**. It has registered its purchase-event address with Plandalf for you, so there are no keys or webhook addresses to copy.
    

If a security or caching plugin protects your site, let `/wp-json/plandalf/v1/events` through. To change account or mode later, click **Disconnect** and connect again; a reconnect keeps the same account and mode.

## Choose your checkout design

Under **Choose your checkout design**, pick the checkout you published, keep **Use Plandalf checkout in place of the MemberPress signup form** ticked and click **Save checkout**. The checkout only sets the look. Each membership page sells its own linked price, so one design can sell every membership.

## Link memberships to prices

A membership is what someone gets access to; a Plandalf price is what they pay. Linking them means buying that price grants that membership.

Under **Link your memberships to Plandalf prices**, click **Create Plandalf price** next to a membership, or **Create Plandalf prices for all** your unlinked memberships. The plugin creates a product and price in Plandalf from the membership's own terms and links them, and the membership page switches to your checkout.

Click **Manage** to open a membership's **Plandalf** tab. There you can:

-   Link more prices to the same membership, such as a yearly plan, with **Link price**, and pick the **Price sold on this page**.
-   See when a price differs from the membership's own terms, then click **Update MemberPress to match Plandalf**, or **Keep the difference** if it's on purpose.
-   Use a different checkout design for this membership.

Memberships with a fixed expiry date or a paid trial can't have a price created from them. Create the price in Plandalf and link it on the Plandalf tab instead.

## Show a checkout on the membership page

On the membership's **Plandalf** tab, **Shown as** sets how the page sells:

Option

What buyers see

Embedded on the membership page (recommended)

The checkout in place of the signup form

Popup from a button

A button that opens the checkout over the page

Full screen from a button

A button that opens the checkout full screen

To keep the MemberPress form on one membership, tick **Keep the MemberPress signup form for this membership**. Leave membership pages out of page caching, so each visitor gets the right checkout.

## Sell a membership from another page

Add the shortcode with the membership's ID (the number in its edit link). It renders a button that opens the checkout over the page:

```text
[plandalf_buy membership="9"]Join now[/plandalf_buy]
```

Add `class="…"` to style the button. If the membership has no linked price or no design, editors see a note in its place and visitors see nothing.

## Protect your content

Plandalf grants the membership; MemberPress rules decide what it unlocks. If your content is already protected, skip this. Otherwise go to **MemberPress → Rules → Add New Rule**, choose the page, set the access condition to your membership and click **Save Rule**. Then set where new members land under the membership's **Membership Options → Advanced → Membership Access URL**.

Check the page signed out. Administrators skip rules, so a locked page looks open while you're signed in.

## Make a test purchase

1.  ### Open the membership page
    
    Use a private window on a site connected in **Test** mode. The checkout sits where the signup form was, with a test mode strip at the top.
    
2.  ### Pay with a test card
    
    Use a new email address you can read and `4242 4242 4242 4242`, any future date and any CVC.
    
3.  ### Wait on the thank-you page
    
    It shows **Activating your membership…** until the plugin has applied Plandalf's purchase event.
    
4.  ### Set the password
    
    A new member goes straight to choosing a password, and gets the same link by email. Someone already signed in sees their membership confirmed.
    
5.  ### Check WordPress
    
    Under **MemberPress → Plandalf**, **Events** lists the purchase as **Applied**. **MemberPress → Transactions** shows it as a normal transaction numbered with its Plandalf invoice.
    

Before going live, also try a declined card (`4000 0000 0000 0002`), a purchase by a member who's already signed in, a cancellation from the MemberPress account page and a refund. More test cards are in [Test mode](https://plandalf.com/docs/get-started/test-mode).

## Go live

1.  ### Connect in Live mode
    
    On your live site, connect with **Live**. To switch a connected site, click **Disconnect**, then connect again.
    
2.  ### Check payments and prices
    
    Make sure your live Stripe account is connected in Plandalf. Link your memberships and open each membership page to check its price.
    
3.  ### Open the way for events
    
    Let `/wp-json/plandalf/v1/events` through your firewall or security plugin, and leave membership pages out of page caching.
    
4.  ### Buy once for real
    
    Make one small real purchase, then refund it.
    

Members already paying through a MemberPress gateway carry on as before. Plandalf takes new purchases, so both run side by side. The plugin doesn't move existing subscriptions.

## After launch

When

What happens in MemberPress

A subscription renews

The membership runs to the end of the new paid period.

A member cancels from the account page

Plandalf cancels the subscription at the end of the period, and access lasts until then.

A payment fails

Stripe retries it on your Stripe retry settings. If Stripe finally cancels the subscription, the membership ends.

You refund in Plandalf

A full refund ends the membership. A partial refund leaves it active.

Every day

The plugin checks subscriptions due in the next 48 hours with Plandalf, in case a renewal or cancellation event was missed.

## Limits

-   Checkout pages after payment, such as upsells, are skipped.
-   Deadline timer pricing doesn't apply on membership pages. The page sells the linked price.
-   MemberPress coupons don't apply. Create discounts in Plandalf.
-   No proration when someone switches memberships in a group.
-   MemberPress corporate (sub-account) memberships aren't supported.
-   There's no billing link on the MemberPress account page. Members update their card from Plandalf's billing emails.

## If something's not right

-   Someone paid but has no membership: look for their invoice under **Events**. If it's missing, a firewall or caching plugin is blocking `/wp-json/plandalf/v1/events`. Let it through and Plandalf keeps retrying. Don't charge them again.
-   An event says **Ignored**: the price they bought isn't linked to a membership on this site. Link it on the membership's **Plandalf** tab.
-   The page still shows the MemberPress form: the membership's **Plandalf** tab says why. Clear your page cache after changing it.
-   No set-password email: check WordPress email and your SMTP plugin.

## For developers

### How the connection works

Since 0.2.0 the plugin connects with OAuth (authorization code with S256 PKCE). No client secret ships in the plugin, and there's no API key to paste. The plugin:

1.  sends the admin to Plandalf's `/connect/site` consent screen with the site URL, an exact return URL on the same site, a random state and a PKCE challenge;
2.  exchanges the returned code at Plandalf's `/oauth/token`;
3.  reads the account, mode, checkout host and SDK URL from `GET /api/v1/site-connection`;
4.  registers `https://your-site/wp-json/plandalf/v1/events` with `POST /api/v1/webhook_endpoints` for `invoice.paid`, `invoice.payment_failed`, `invoice.refunded`, `subscription.updated` and `subscription.canceled`.

Access and refresh tokens are stored encrypted with a key from the site's authentication salt, so changing the salts means reconnecting. For signed-in members, Plandalf signs a five-minute identity token through `POST /api/v1/site-connection/identity`, with `sub` set to `wp:` plus the WordPress user ID; WordPress never holds the signing key. **Disconnect** calls `DELETE /api/v1/site-connection`, which revokes the tokens and removes the event endpoint. See [Site connection](https://plandalf.com/docs/api/site-connection).

### Events

Every request is signed. The plugin rejects a bad signature or a timestamp more than five minutes old, stores each event ID so it never applies one twice, and grants only from invoice lines whose `links` grant a membership on this site. How to check signatures yourself is in [Verify signatures](https://plandalf.com/docs/api/verify-signatures); the payloads are in [Webhooks](https://plandalf.com/docs/api/webhooks).

### Other API calls

The plugin also uses `GET /api/v1/offers`, `GET /api/v1/prices`, `POST /api/v1/products`, `POST /api/v1/prices`, the [links endpoints](https://plandalf.com/docs/api/links) for price-to-membership links and drift, and `GET /api/v1/subscriptions/{subscription}` and `POST /api/v1/subscriptions/{subscription}/cancel` for the daily check and account-page cancellation. None of these are specific to MemberPress.

### Hooks

```php
// Change the identity token's claims before Plandalf signs it.
add_filter('plandalf_mepr_identity_claims', function (array $claims, WP_User $user) {
    return $claims;
}, 10, 2);

// Pick the WordPress user for an event. Return a WP_User to override matching.
add_filter('plandalf_mepr_resolve_user', function (?WP_User $user, array $event) {
    return $user;
}, 10, 2);

// Runs after a membership is granted or extended.
add_action('plandalf_mepr_granted', function (MeprTransaction $txn, array $event) {}, 10, 2);

// Runs for every verified event, including ones the plugin ignores.
add_action('plandalf_mepr_event', function (array $event) {}, 10, 1);
```

The source, issues and a test suite you can run with `wp eval-file` are on [GitHub](https://github.com/plandalf/memberpress).

Something wrong or missing? Email [hello@plandalf.com](mailto:hello@plandalf.com).
