Sometimes you may want to perform a custom action when certain events occur within your membership site. For example, you may want to update a 3rd party database when members join or cancel. Or you may want to update a 3rd party application when a payment is received. MemberMouse's powerful push notification system can be used to accomplish these things and a lot more. Read this article to learn more about using push notifications.



In this article, we'll cover the following:


  1. Setting Up the Push Notification

  2. Accessing Data in Your Script

  3. Testing Your Script

  4. Troubleshooting

1. Setting Up the Push Notification


  1. From the WordPress Dashboard, go to MemberMouse > Developer Tools and then click on the Push Notifications tab.

  2. Click the  button and a dialog will pop up where you'll configure the notification.

  3. Make sure that Status is set to Active.

  4. Under the When the following event occurs... heading, select the event from the drop down that you want to trigger your custom script being called. For certain events, there are also secondary options that can be set. For example, For the Member Status Changed event you can optionally select a specific status to trigger the script being called.




  5. Under the Perform the following action... heading, select Call a Custom Script from the drop down.






  6. Next, enter the URL where your custom script is located.






  7. Click the button.


2. Accessing Data in Your Script


MemberMouse will call the script you specify and pass any relevant data based on the event that triggers the notification. The table below maps events to sample scripts that show you what data will be passed for each event and how to access it:



EventSample Script
Member Added

Member Account Updated

Member Status Changed

Membership Level Changed

Member Deleted
Member Notification Script

Bundle Added

Bundle Status Changed
Bundle Notification Script
Payment Received

Rebill Payment Received

Rebill Payment Failed

Refund Issued


 
Payment Notification Script
Affiliate Commission (Initial)

Affiliate Commission (Rebill)

Cancel Affiliate Commission


Affiliate Notification Script
Product Purchased

Product Purchased Notification Script



3. Testing Your Script


When you're developing your script you can easily test it from the Developer Tools > Push Notifications page by clicking the  icon on the row associated with the notification you want to test. This will send test data to the script configured in the notification. While the test notification tool is useful, prior to going live with your script, it's always a good idea to run a real world test.



4. Troubleshooting


If you end up in a situation where it seems like push notification data is not being passed to your script, we suggest uploading the following the instructions below:

  1. Download the test script: Push Notification Test Script

  2. Upload the test script to your server. For the sake of example let's assume that you upload the script to http://yourdomain.com/push_notification_test.php. This simple test script will send an email to the email address passed to the script along with some data that would've been passed to the script from the MemberMouse push notification system.

  3. Create a new push notification for the event you want to test and set the URL to the location of the test script as follows:

    http://yourdomain.com/push_notification_test.php?to_email=<your_email_address>

    IMPORTANT: Make sure to replace <your_email_address> with  your actual email address.

  4. Click the icon to test the push notification. Shortly after this, you should receive an email containing some sample data in it that looks something like this:

    Data passed to script:
    Member ID: -10
    Name: SampleFirstName SampleLastName
    Email: sample@yourdomain.com
    Membership Level: Free Membership