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 due.
MemberMouse's powerful push notification system can be used to accomplish these things, and so can the Payment Reminders. Both systems can be used to trigger scripts on special events.
Read this article to learn more about using push notifications.
Read this article to learn more about payment reminders.
Setting Up the Push Notification or Payment Reminder
- For Push Notifications: From the WordPress Dashboard, go to MemberMouse > Developer Tools and then click on the Push Notifications tab.
For Payment Reminders: From the WordPress Dashboard, go to MemberMouse > Payment Settings and then click on the Reminders tab. - Click the green Create button and a dialog will pop up where you'll configure the notification.
- Make sure that Status is set to Active.
- For Push Notifications: 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.
For Payment Reminders: Under the When to send… heading, enter the desired timing trigger. - 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 Save button.
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:
Event | Sample 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 |
Testing Your Script
When you're developing your script you can easily test it from the Developer Tools > Push Notifications page by clicking the ‘green test beaker' 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.
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:
- 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: 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. - Click the ‘green test beaker' 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: [email protected]
Membership Level: Free Membership