Hooks are provided by WordPress to allow your plugin to ‘hook into' the rest of WordPress; that is, to call functions in your plugin at specific times, and thereby set your plugin in motion. MemberMouse defines its own set of hooks that you can utilize to ‘hook into' MemberMouse so you can call functions in your plugin when specific events occur in MemberMouse.
Here's a basic example:
function memberAdded($data)
{
// perform action
}
add_action('mm_member_add', 'memberAdded');
In this example, we're using the ‘add_action()‘ method to indicate that the ‘memberAdded() ‘method should be called when MemberMouse executes a ‘mm_member_add' action. To learn more about working with WordPress' Action API read this article.
Categories of WordPress Hooks
MemberMouse Action Reference
The following table lists all of the MemberMouse actions, a description of when they're executed and what data will be passed to any function hooked into the action.
Action | Description | Data Passed |
mm_member_add | This action is executed when a new member is added to MemberMouse. | member data |
mm_member_membership_change | This action is executed when a member's membership level is changed. | member data |
mm_member_status_change | This action is executed when the status of a member's account changes. | member data |
mm_member_account_update | This action is executed when certain data on a member's account is updated. This includes: first name, last name, email address, username, phone number, notes, billing address, shipping address, days as member calculation method and custom field data. | member data |
mm_member_delete | This action is executed when a member's account is deleted. | member data |
mm_bundles_add | This action is executed when a bundle is added to a member's account. | member data, bundle data |
mm_bundles_status_change | This action is executed when the status of a bundle changes on a member's account. | member data, bundle data |
mm_product_purchase | This action is executed when an order is submitted, prior to validation and payment. | member data, order data |
mm_purchase_complete | This action is executed when a purchase is completed. It is available in MemberMouse 3.0.6 and newer. | member data, order data |
mm_payment_received | This action is executed when a payment is received. | member data, order data |
mm_payment_rebill | This action is executed when a rebill payment is received. | member data, order data |
mm_payment_rebill_declined | This action is executed when a rebill payment is declined. | member data, order data |
mm_refund_issued | This action is executed when a refund is issued. | member data, order data |
mm_commission_initial | This action is executed when an initial affiliate commission should be tracked. | affiliate data |
mm_commission_rebill | This action is executed when a rebill affiliate commission should be tracked. | affiliate data |
mm_commission_cancel | This action is executed when an affiliate commission should be canceled. | affiliate data |
Data Attributes by Type
All data is passed to functions as an associative array and can be accessed as follows:
$data["first_name"]
$data["last_name"]
$data["email"]
The sections below list the data attributes available for each type.
Member Data
Attribute | Description |
member_id | The ID assigned to the member by MemberMouse. |
registered | The date the member registered in the format YYYY-MM-DD HH:MM:SS. |
last_logged_in | The date the member last logged in in the format YYYY-MM-DD HH:MM:SS. |
last_updated | The date the member's account was last updated in the format YYYY-MM-DD HH:MM:SS. |
days_as_member | The number of days the member has been a member. |
status | The status of the member's account as an integer: 1 = active, 2 = canceled, 3 = locked, 4 = paused, 5 = overdue, 6 = pending activation, 7 = error, 8 = expired, 9 = pending cancellation |
status_name | The status of the member's account as a string (i.e. active, canceled, etc). |
is_complimentary | This indicates if the member's account is complimentary or not. It will be set to ‘true' if the account is complimentary and ‘false' if not. |
membership_level | The ID of the membership level associated with the member's account. |
membership_level_name | The name of the membership level associated with the member's account. |
first_name | The member's first name. |
last_name | The member's last name. |
username | The member's username. |
email | The member's email address. |
phone | The member's phone number. |
cf_# | Outputs the member's value for the custom field with ID #. For example, if the ID of the custom field that stores birthday is 4 then to output the member's birthday you would use ‘cf_4'. |
billing_address | The member's billing address. |
billing_city | The member's billing city. |
billing_state | The member's billing state. |
billing_zip_code | The member's billing zip code. |
billing_country | The member's billing country. |
shipping_address | The member's shipping address. |
shipping_city | The member's shipping city. |
shipping_state | The member's shipping state. |
shipping_zip_code | The member's shipping zip code. |
shipping_country | The member's shipping country. |
Bundle Data
Attribute | Description |
bundle_id | The ID of the bundle. |
bundle_name | The name of the bundle. |
days_with_bundle | The number of days the bundle has been active on the member's account. |
bundle_status | The status of the bundle: 1 = active, 2 = canceled, 3 = locked, 4 = paused, 5 = overdue, 6 = pending activation, 7 = error, 8 = expired, 9 = pending cancellation |
bundle_is_complimentary | This indicates if the bundle is complimentary or not. It will be set to ‘true' if the bundle is complimentary and ‘false' if not. |
bundle_status_name | The status of bundle as a string (i.e. active, canceled, etc). |
bundle_date_added | The date the bundle was added to the member's account in the format YYYY-MM-DD HH:MM:SS. |
bundle_last_updated | The date the bundle was last updated on the member's account in the format YYYY-MM-DD HH:MM:SS. |
Order Data
Attribute | Description |
order_number | The reference number assigned to the order by MemberMouse. |
order_transaction_id | The transaction ID associated with the order. This can be used as a unique ID for all payments associated with an order. When a customer purchases a subscription, each rebill payment is part of the same order so they'll all share the same order ID. Each rebill payment will have a unique transaction ID. |
order_total | The order total which equals (subtotal – discount) + shipping. |
order_subtotal | The order subtotal. |
order_discount | The discount applied to the order. |
order_shipping | Shipping cost applied to the order. |
order_shipping_method | The name of the shipping method chosen by the customer when checking out. |
order_billing_address | The billing address associated with the order. |
order_billing_city | The billing city associated with the order. |
order_billing_state | The billing state associated with the order. |
order_billing_zip_code | The billing zip code associated with the order. |
order_billing_country | The billing country associated with the order. |
order_shipping_address | The shipping address associated with the order. |
order_shipping_city | The shipping city associated with the order. |
order_shipping_state | The shipping state associated with the order. |
order_shipping_zip_code | The shipping zip code associated with the order. |
order_shipping_country | The shipping country associated with the order. |
order_products | An array of products associated with the order. See the Product Data table below for parameters available for each product. |
order_coupons | An array of coupons associated with the order. See the Coupon Data table below for parameters available for each coupon. |
order_prorations | An array of prorations associated with the order. See the Proration Data table below for parameters available for each proration item. |
order_affiliate_id | The affiliate ID associated with the order. |
order_subaffiliate_id | The subaffiliate ID associated with the order. |
order_ip_address | The IP Address associated with the order. |
Affiliate Data
Attribute | Description |
order_affiliate_id | The affiliate ID associated with the order. |
order_subaffiliate_id | The subaffiliate ID associated with the order. |
member_id | The ID assigned to the member by MemberMouse. |
order_number | The unique number associated with the order concatenated with the transaction ID associated with the payment (i.e. 1456-3462). This ensures that the order number provided here is unique across all rebill transactions associated with the order. |
order_total | The order total available for commissions which equals the order total minus discounts and shipping costs. |
order_ip_address | The IP Address associated with the order. |
order_products | An array of products associated with the order. See the Product Data table below for parameters available for each product. |
order_coupons | An array of coupons associated with the order. See the Coupon Data table below for parameters available for each coupon. |
order_prorations | An array of prorations associated with the order. See the Proration Data table below for parameters available for each proration item. |
rebill_commission_flat_rate | This will only be included on commission rebill events. Based on the commission profile applied to the order, this indicates if there's a flat rate commission override that should be taken into account. |
rebill_commission_percent | This will only be included on commission rebill events. Based on the commission profile applied to the order, this indicates if there's a percentage commission override that should be taken into account. |
Product Data
Product data is stored as an array of JSON-encoded objects in the ‘order_products' attribute and is included with Order Data and Affiliate Data. Prior to interacting with the array make sure to JSON decode is as follows:
json_decode(stripslashes($data["order_products"]);
This sample code assumes that the data was passed to your script in variable called ‘$data'. The table below outlines the available parameters for each item in the ‘order_products' array.
Attribute | Description |
id | The ID of the product. |
name | The name of the product. |
sku | The SKU for the product. |
amount | The amount paid for each unit of the product. |
quantity | The number of this product purchased. |
total | The total price paid equivalent to amount * quantity. |
is_recurring | Indicates where this product has a subscription associated with it or not. Possible values are ‘true' or ‘false'. |
recurring_amount | The amount paid each rebill period. |
rebill_period | An integer representing the rebill period length. To determine the complete rebill period length, combine this with rebill_frequency (i.e. 1 months, 30 days, 2 weeks, etc). |
rebill_frequency | An string indicating the unit of measure used for the rebill period. Possible values are days, weeks, months, or years. |
Coupon Data
Coupon data is stored as an array of JSON-encoded objects in the ‘order_coupons' attribute and is included with Order Data and Affiliate Data. Prior to interacting with the array make sure to JSON decode is as follows:
json_decode(stripslashes($data["order_coupons"]);
This sample code assumes that the data was passed to your script in variable called ‘$data'. The table below outlines the available parameters for each item in the ‘order_coupons' array.
Attribute | Description |
id | The ID of the coupon. |
name | The name of the coupon. |
code | The coupon code. |
Proration Data
Proration data is stored as an array of JSON-encoded objects in the ‘order_prorations' attribute and is included with Order Data and Affiliate Data. Prior to interacting with the array make sure to JSON decode is as follows:
json_decode(stripslashes($data["order_prorations"]);
This sample code assumes that the data was passed to your script in variable called ‘$data'. The table below outlines the available parameters for each item in the ‘order_prorations' array.
Attribute | Description |
amount | The amount of the proration. |
description | The description associated with the purchase. |