How To Downgrade A Paid MemberMouse Subscription to A Free Membership Level After They Cancel

Scenario:  Let’s say you have a paid and a free membership level in MemberMouse.  When a user cancels their paid subscription you might need to downgrade the user to a Free Level so that they retain access to any bundles they purchased separately.  To do that you will need this little script.

 

In this case I have a Push Notification setup to call a custom script which is a Zapier webhook.

membermouse-push-notification

 

The zap catches the information from MemberMouse and then posts it to my script hosted on a server elsewhere.  The only variable I need to pass is the ‘member_id’.

downgrade-step1 downgrade-step5

 

Why don’t I POST it directly to the script?

You absolutely could with a slight modification.  Mostly because I am lazy and don’t want to parse the data that MemberMouse sends.  If you post it to http://requestb.in you will see something like

[code]

?shipping_address=(u’123 Sample St.’,)&membership_level_id=(u’1′,)&shipping_zip_code=(u’12345′,)&billing_country=(u’United States’,)&shipping_state=(u’NY’,)&q=(u’/updateMember’,)&registered=(u’2014-08-15 03:13:26′,)&billing_address=(u’123 Sample St.’,)&apisecret=(XXX’,)&phone=(u'(555) 555-5555′,)&status=(u’1′, u’2′)&first_name=(u’SampleFirstName’,)&billing_city=(u’Sample City’,)&last_updated=(u’2014-08-15 03:13:26′,)&member_id=(u’-10′,)&email=(u’sample@yourdomain.com’,)&billing_state=(u’NY’,)&shipping_country=(u’United States’,)&is_complimentary=(u’false’,)&membership_level_name=(u’Free Membership’,)&membership_level=(u’1′,)&username=(u’sampleusername’,)&last_name=(u’SampleLastName’,)&status_name=(u’Canceled’,)&days_as_member=(u’1′,)&billing_zip_code=(u’12345′,)&event_type=(u’mm_member_status_change’,)&shipping_city=(u’Sample City’,)&apikey=(XXX’,)&last_logged_in=(u’2014-08-15 03:13:26′,)

[/code]

Which means I’d have to cut out some of the extraneous data.  Zapier handles that for me and I was in a hurry to have it live.

 

8 Comments

  1. Richard Steele on March 9, 2015 at 5:23 pm

    I need a custom script for a membermouse push notification, I have integrated membermouse with iDevaffiliate and I am using the feature that makes all members automatic affiliates when they join my site. However I also need them to be automatically cancelled as affiliates when they cancel their site memberships but this is only possible by using a custom script that is triggered by a cancellation to hit the iDev API and remove that affiliate. I have no clue where to start when it comes to these custom scripts and have no idea where I can find someone to write this script for me! Any help or advice on this would be much appreciated

    • Darren Crawford on March 9, 2015 at 5:28 pm

      I’d hit up elance.com or odesk.com. Probably $25-$50 to get something like that done.

      • Richard Steele on March 9, 2015 at 8:48 pm

        Ok great thanks for that, I’ll give them a try!

      • Richard Steele on March 10, 2015 at 1:26 pm

        Hi

        I’ve tried the sites and also peopleperhour, but the developers on there are trying to tell me its a major job and quoting me hundreds, are they trying to pull a fast one over me or is there more work involved than $50 would cover?

        • Darren Crawford on March 10, 2015 at 1:40 pm

          http://www.idevkb.com/article.php?id=28 shows integration of the API with a custom cart. One page 1 of the PDF they show the example script. I cannot find documentation on the actual API for idev though… so I cannot give you the exact process. I’d ask them if they can provide it to you.

          Then you just need a script like I have on this page and change the curl section near the bottom to point to iDev. It shouldn’t be more complicated than that… Unless… there is no mechanism in the API for canceling users access to it.

          If that is the case, and you don’t get a lot of these, then what I would do is have MemberMouse send me an email with the details of the canceled user and I or somebody on my team could manually cancel them in iDev. Not fully automated but probably not a big problem to solve either.

          • Richard Steele on March 10, 2015 at 3:50 pm

            Thanks for your advice I really appreciate you taking the time to reply to me as this is really messing my head up as I’m really not technically advanced enough for this type of thing.
            I found this article in the iDev tutorial for API scripts but its gobbledy gook to me but does this mean its possible to do what I want to do…..

            Create Your Own API Script
            We have included a blank API script for you to develop with.  Duplicate it unlimited times to perform unlimited tasks.  
            The blank template is located here: /API/scripts/idevaffiliate_api.php
            You might consider running this API script via CRON, cURL or even in a web browser. When calling the file, you’ll need to
            pass the “secret” argument in the URL.
            Example, if your secret number is 4556764324, you’ll need to call this file like this:
            http://www.yoursite.com/idevaffiliate/API/idevaffiliate_api.php?secret=4556764324
            You can find your secret key by logging into your iDevAffiliate admin center.  In the upper right section of the main page,
            click on System Information. The secret key is located on this page.
            Support
            Support for this feature is very limited. We always try to help as much as possible by giving definitions of the database
            tables and fields but for us to actually write these functions for you is very rare. We simply have too many customers to
            support and have very little time to work on customizations. We can certainly recommend qualified PHP developers that
            are familiar with iDevAffiliate to help you with these custom functions.
            If you have any questions, please do not hesitate to open a support ticket at http://www.idevsupport.com.



  2. Nigel Fish on September 14, 2015 at 5:02 pm

    You can really skip both zapier and the push notification thing by simply placing the script directly into the “mm_member_status_change” WordPress Hook.

    e.g. straight into functions.php:

    function memberChangedStatus($memberdata) {
    if ($memberdata[“status”] == 2) {
    //if they cancel, don’t cancel, change to free.
    $member_id = $memberdata[“member_id”];
    $apikey = ‘API_KEY’;
    $apisecret = ‘API_SECRET’;

    $inputParams = “apikey=”.$apikey.”&apisecret=”.$apisecret.”&”;
    $inputParams .= “member_id=”.$member_id.”&”;
    $inputParams .= “membership_level_id=1&”;

    $apiCallUrl = “?q=/updateMember”;
    $ch = curl_init($apiCallUrl);

    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $inputParams);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_exec($ch);
    curl_close($ch);
    }

    }

    add_action(‘mm_member_status_change’, ‘memberChangedStatus’);

    MIND YOU, I think it’s bananas that one is curling back to their own server. Should just be able to make a function call, but that’s membermouses fault IMO.

    • Darren Crawford on September 14, 2015 at 5:20 pm

      That’s fancy… and WAY cleaner. Thanks for sharing it Nigel.

Leave a Comment