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
From the WordPress Dashboard, go to MemberMouse > Developer Tools and then click on the Push Notifications tab.
Click the button and a dialog will pop up where you'll configure the notification.
Make sure that Status is set to Active.
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.
Under the Perform the following action... heading, select Call a Custom Script from the drop down.
Next, enter the URL where your custom script is located.
- 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:
Member Account Updated
Member Status Changed
Membership Level Changed
|Member Notification Script|
Bundle Status Changed
|Bundle Notification Script|
Rebill Payment Received
Rebill Payment Failed
|Payment Notification Script|
|Affiliate Commission (Initial)
Affiliate Commission (Rebill)
Cancel Affiliate Commission
|Affiliate 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.
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:
- Download the test script: Push Notification Test Script
- 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.
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:
IMPORTANT: Make sure to replace
<your_email_address>with your actual email address.
- 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
Membership Level: Free Membership