MemberMouse is a great membership solution for a WordPress website and, recently, after I have wrote the MemberMouse integration with PayKickstart article, the same customer which we have here on MemberFix, requested a solution for users to be able to upgrade their membership directly from their Dashboard page on the website.

Shortly, this customer uses the MemberMouse membership plugin to protect his content, and PayKickstart (PKS) as his checkout and funnels solution.

So, in this case, PKS is the app which manages all of the members’ billing. So, for example, let’s say that you have a WordPress website which uses MemberMouse and PKS with 3 membership levels: “Bronze Membership”, “Gold Membership” and “Platinum Membership”.

We need a possibility for “Bronze Membership” users to be able to upgrade their membership level to “Gold Membership” or “Platinum Membership” directly from their account page on website. When they choose to buy “Gold Membership” or “Platinum Membership” then PKS records the payment and MemberMouse is notified and the membership level and bundle (if it is the case) are updated.

We will do this using our friend Zapier and here are the steps:

1 – Login to your Zapier account, click here and accept the private invitation to PayKickstart Zapier integration.

2 – Then visit “Connected Accounts” inside of Zapier, type Pay in the top search box and you will be able to see “PayKickstart (1.0.0) By Invite”. Click on it.

3 – A pop-up window will appear. Add Your PayKickstart API Key in Zapier. Your API Key can be found in the top right navigation “Platform Settings” of PayKickstart. Note: You must be on the Professional or Premium plan to use this feature.

4 – On your Zapier account page click on top button “Make a Zap!”.

5 – Choose a trigger app by clicking on PayKickstart icon or by typing “PayKickstart” in the search field if the icon is not visible. Then click on “Continue” button.

6 – Choose New Order as trigger on the next page. Then click on “Continue” button.

7 – On the next page you will see the PayKickstart + Zapier connection. Click on “Continue”.

8 – On the next page you will need to select the PayKickstart campaign and products.

9 – On the next page you see the successful test.

10 – Next go to Action section of the Zap and choose “Webhooks” which it is listed under “Built-in Apps”.

11 – On the next page select GET and click on “Continue” button.

12 – The next page will need more work and I will explain this in more detail. You need access to your website FTP. Just duplicate the page.php file from your theme files and name it upgrade-test-page.php. Open upgrade-test-page.php and add this to the top of it:

<?php

/* Template Name: Upgrade Test */

?>

We have just created a template WordPress file.

13 – Go to your WordPress Dashboard and click on Pages => Add New. Name the page “Upgrade Test” and select Upgrade Test as page template. So the link to the page will be yourdomain.com/upgrade-test/.

14 – Go back to your Zapier page Action => Edit template and do the following settings:

So, for the URL section just add the address to the page we have created on WordPress ( https://yourdomain.com/upgrade-test/ or http://yourdomain.com/upgrade-test/ ). Then we will select Product as the first parameter which we will need to send and name it “product”. The second parameter is Buyer Email and we will name it “buyer_email”.

15 – Now we will need to add some php code to the page template which we have created. Open upgrade-test-page.php and just below the opening <body> tag add the below code:

<?php

global $wpdb;

// get the two parameters from Zapier

$user_email = $_GET[‘buyer_email’];

$membership_level = $_GET[‘product’];

// get user ID from wp_users table

$user_id = $wpdb>get_var(“SELECT ID FROM wp8c_users WHERE user_email = ‘$user_email‘”);

// add the new membership to the user in the database
if ($membership_level == ‘Gold Membership’ )

{

$wpdb>update(
‘mm_user_data’,
array(
‘membership_level_id’ => membership id here (a number)
),
array( ‘wp_user_id’ => $user_id ),
array(
%d
),
array( %d )
);

} else if ($membership_level == ‘Platinum Membership’ )

{

$wpdb>update(
‘mm_user_data’,
array(
‘membership_level_id’ => membership id here (a number)
),
array( ‘wp_user_id’ => $user_id ),
array(
%d
),
array( %d )
);
}

// add the new bundle to the user in the database
if ($membership_level == ‘Gold Membership’ )

{

$wpdb>update(
‘mm_applied_bundles’,
array(
‘bundle_id’ => bundle id here (a number)
),
array( ‘access_type_id’ => $user_id ),
array(
%d
),
array( %d )
);

} else if ($membership_level == ‘Platinum Membership’ )

{

$wpdb>update(
‘mm_applied_bundles’,
array(
‘bundle_id’ => bundle id here (a number)
),
array( ‘access_type_id’ => $user_id ),
array(
%d
),
array( %d )
);
}

?>

So basically the code above is inserting into the database the membership lever ID and Bundle ID for every user whenever a new order happens on PayKickstart.

16. We are done! 🙂

I’m a web and graphic designer. I have an extensive experience in WordPress and I like working here at MemberFix.

Shares
Share This