# Kirby Memberkit - A subscription-based membership Plug-In powered by Stripe

**URL:** <https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500>\
**Category:** Plugins\
**Tags:** v3\
**Created:** [March 8, 2021, 8:38am UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500 "2021-03-08T08:38:14Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manuel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/manuel/32/9795_2.png) [@Manuel](https://forum.getkirby.com/u/Manuel)\
**Post date:** [March 8, 2021, 8:38am UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/1 "2021-03-08T08:38:14Z")

</div>

> A versatile Kirby User Membership Plug-In powered by Stripe Subscriptions for Kirby CMS.

For a couple of ideas with Kirby CMS, I thought it would be nice to have a lean membership functionality powered by Stripe (Checkout & Customer Portal).

I put a lot of effort into the [README](https://github.com/kreativ-anders/kirby-memberkit/blob/main/README.md) file to describe as most straightforward and easy as possible how to use the Plug-In and how the Plug-In is working. In case I missed anything please feel free to ask! ✌🏻

> **[GitHub - kreativ-anders/kirby-memberkit: Kirby Memberkit - A versatile Kirby User...](https://github.com/kreativ-anders/kirby-memberkit)**
>
> Kirby Memberkit - A versatile Kirby User Membership Plug-In powered by Stripe Subscriptions for Kirby CMS.

**Attached some screenshots (since pictures say more than words) …**

_1. User registration with [Kirby Userkit Add-On](https://github.com/kreativ-anders/kirby-userkit) on top of [Kirby´s Starterkit v3.5.3.1](https://github.com/getkirby/starterkit/):_

 ![10 Register](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/c/c93ee0f700ded5e14d73e5ca7161d2cbe0efde72.png)

* * *

_2. Show (debug) information within the intro.php snippet:_

 ![20 Register Successfull](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/1/1de9fcfcc8f07462db02f6b9ba148ee030033159.jpeg)

* * *

_3. Stripe Checkout:_

 ![30 Stripe Checkout](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/7/76d9cbf0dd0b4052e4fe72079e111905050d442f.png)

* * *

_4. Redirect after successful checkout:_

 ![40 Stripe Checkout Successfull](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/9/9d418c62d67dad86dc30daaadaa1f8385c0e60c7.jpeg)

* * *

1. Start the Stripe CLI within VS Code:

 ![45 VS Code Start Listener](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/a/ae77f84ff1c56eb71a9d424cf272a9e1f917b340.png)

* * *

_6. Stripe Customer Portal:_

 ![50 Stripe Customer Portal](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/7/73df82754f55f48627bbc807eb38a5ff8d9cdad8.png)

* * *

_7. Stripe Customer Portal - Change plan to yearly:_

 ![60 Stripe Customer Portal Change Plan Yearly](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/f/f4093ed7cf3d24a0f1f1cdbaf899f754fffcf816.png)

* * *

_8. Stripe Customer Portal - Change Email:_

 ![70 Stripe Customer Portal Change Email](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/1/1b2365c6d3ea8b52f994e70a363339a891994f5a.png)

* * *

_9. Redirect after successful Stripe Customer Portal_

 ![80 Stripe Customer Portal Successfull](https://europe1.discourse-cdn.com/flex017/uploads/getkirby/original/2X/5/5ca6a08bb66e23e5476cac15c7a42523f3f6d29f.jpeg)

---

<div class="post-metadata">

**Author:** ![mrfreedom](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/mrfreedom/32/14018_2.png) [@mrfreedom](https://forum.getkirby.com/u/mrfreedom)\
**Post date:** [March 8, 2021, 5:37pm UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/2 "2021-03-08T17:37:19Z")

</div>

Bravo 👏

---

<div class="post-metadata">

**Author:** ![Manuel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/manuel/32/9795_2.png) [@Manuel](https://forum.getkirby.com/u/Manuel)\
**Post date:** [March 12, 2021, 5:24pm UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/3 "2021-03-12T17:24:21Z")

</div>

**You need to [migrate existing users](https://github.com/kreativ-anders/kirby-memberkit#migrate-existing-users)** otherwise, the Plug-In may fail at some point.  
To support you, you can now call a dedicated users method for this:

```
$kirby->users()->migrateStripeCustomers();

```

✌🏻

---

<div class="post-metadata">

**Author:** ![johan](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/johan/32/7322_2.png) [@johan](https://forum.getkirby.com/u/johan)\
**Post date:** [March 14, 2021, 12:03am UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/4 "2021-03-14T00:03:00Z")

</div>

I’m currently building a membership site with Kirby + Memberstack. This looks fantastic!

---

<div class="post-metadata">

**Author:** ![Manuel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/manuel/32/9795_2.png) [@Manuel](https://forum.getkirby.com/u/Manuel)\
**Post date:** [April 6, 2021, 5:33pm UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/5 "2021-04-06T17:33:27Z")

</div>

When a Kirby user has been created, the Kirby hook (“user.create:after”) writes the stripe customer id into the Kirby user. [→ Check out the source code](https://github.com/kreativ-anders/kirby-memberkit/blob/main/hooks.php#L13)

```
Stripe-customer: cus_JFnUXXXXXXX
----
Tier: Basic

```

_(Also, the user will be logged in after successful creation.)_

Recently, I added another hook within the config.php (“user.login:after”) to capture the last login within the Kirby user:

```
'hooks' => [
    'user.login:after' => function ($user, $session) {
      $user->update([
        'lastLogin' => date("m.d.Y")
      ]);
    }
  ],

```

**Now, the Plug-In hook (“user.create:after”) is able to create the stripe customer successfully but fails to update the Kirby user (no exception/error), and surprisingly the hook (“user.login:after”) is able update the Kirby user!** 🤯

I have no clue what is going on …

@texnixe @lukasbestle

… Do you have an idea?  
Or could you tell me more about the execution sequence of Kirby hooks please?  
(Is it possible that one hook blocks the other to update the user?)

---

<div class="post-metadata">

**Author:** ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)\
**Post date:** [April 6, 2021, 5:55pm UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/6 "2021-04-06T17:55:14Z")

</div>

> [@Manuel](#):
>
> (Also, the user will be logged in after successful creation.)

Where in your code is the user logged in?

---

<div class="post-metadata">

**Author:** ![lukasbestle](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/lukasbestle/32/11437_2.png) [@lukasbestle](https://forum.getkirby.com/u/lukasbestle)\
**Post date:** [April 6, 2021, 6:50pm UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/7 "2021-04-06T18:50:29Z")

</div>

Unfortunately that’s a known issue that’s very hard to fix with our current immutable objects:

> <https://github.com/getkirby/kirby/issues/2828>
>
> Describe the bug
> When having multiple plugins using the same hook to update() the $file or $page object, only one change actually...

---

<div class="post-metadata">

**Author:** ![Manuel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/manuel/32/9795_2.png) [@Manuel](https://forum.getkirby.com/u/Manuel)\
**Post date:** [April 7, 2021, 6:17am UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/8 "2021-04-07T06:17:08Z")

</div>

> [@texnixe](#):
>
> Where in your code is the user logged in?

In the [“registration” controller.php](https://github.com/kreativ-anders/kirby-userkit/blob/main/site/controllers/register.php) that equals the process from the userkit Add-On.

---

<div class="post-metadata">

**Author:** ![Manuel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/manuel/32/9795_2.png) [@Manuel](https://forum.getkirby.com/u/Manuel)\
**Post date:** [April 7, 2021, 6:21am UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/9 "2021-04-07T06:21:05Z")

</div>

> [@lukasbestle](#):
>
> Unfortunately that’s a known issue that’s very hard to fix with our current immutable objects:

Oh, damn. Sounds very hard to fix as well 😑.

Thanks, both to you for the quick response! 👏🏻

---

<div class="post-metadata">

**Author:** ![John2202](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@John2202](https://forum.getkirby.com/u/John2202)\
**Post date:** [February 2, 2022, 11:30pm UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/10 "2022-02-02T23:30:41Z")

</div>

Is there a way to restrict users from some pages before subscription and give access after subscription

---

<div class="post-metadata">

**Author:** ![Manuel](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/manuel/32/9795_2.png) [@Manuel](https://forum.getkirby.com/u/Manuel)\
**Post date:** [February 3, 2022, 2:19pm UTC](https://forum.getkirby.com/t/kirby-memberkit-a-subscription-based-membership-plug-in-powered-by-stripe/21500/11 "2022-02-03T14:19:46Z")

</div>

Does this help?

> **[Restricting access to your site](https://getkirby.com/docs/cookbook/security/access-restriction#protecting-content__protecting-entire-pages)**
>
> Use Kirby’s authentication system to build login-protected pages.
