fbpx

MemberMouse WordPress Hooks

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.

ActionDescriptionData Passed
mm_member_addThis action is executed when a new member is added to MemberMouse.member data
mm_member_membership_changeThis action is executed when a member's membership level is changed.member data
mm_member_status_changeThis action is executed when the status of a member's account changes.member data
mm_member_account_updateThis 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_deleteThis action is executed when a member's account is deleted.member data
mm_bundles_addThis action is executed when a bundle is added to a member's account.member databundle data
mm_bundles_status_changeThis action is executed when the status of a bundle changes on a member's account.member databundle data
mm_product_purchaseThis action is executed when an order is submitted, prior to validation and payment.member dataorder data
mm_purchase_completeThis action is executed when a purchase is completed. It is available in MemberMouse 3.0.6 and newer.member dataorder data
mm_payment_receivedThis action is executed when a payment is received.member dataorder data
mm_payment_rebillThis action is executed when a rebill payment is received.member dataorder data
mm_payment_rebill_declinedThis action is executed when a rebill payment is declined.member dataorder data
mm_refund_issuedThis action is executed when a refund is issued.member dataorder data
mm_commission_initialThis action is executed when an initial affiliate commission should be tracked.affiliate data
mm_commission_rebillThis action is executed when a rebill affiliate commission should be tracked.affiliate data
mm_commission_cancelThis 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
AttributeDescription
member_idThe ID assigned to the member by MemberMouse.
registeredThe date the member registered in the format YYYY-MM-DD HH:MM:SS.
last_logged_inThe date the member last logged in in the format YYYY-MM-DD HH:MM:SS.
last_updatedThe date the member's account was last updated in the format YYYY-MM-DD HH:MM:SS.
days_as_memberThe number of days the member has been a member.
statusThe 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_nameThe status of the member's account as a string (i.e. activecanceled, etc).
is_complimentaryThis 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_levelThe ID of the membership level associated with the member's account.
membership_level_nameThe name of the membership level associated with the member's account.
first_nameThe member's first name.
last_nameThe member's last name.
usernameThe member's username.
emailThe member's email address.
phoneThe 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_addressThe member's billing address.
billing_cityThe member's billing city.
billing_stateThe member's billing state.
billing_zip_codeThe member's billing zip code.
billing_countryThe member's billing country.
shipping_addressThe member's shipping address.
shipping_cityThe member's shipping city.
shipping_stateThe member's shipping state.
shipping_zip_codeThe member's shipping zip code.
shipping_countryThe member's shipping country.
Bundle Data
AttributeDescription
bundle_idThe ID of the bundle.
bundle_nameThe name of the bundle.
days_with_bundleThe number of days the bundle has been active on the member's account.
bundle_statusThe 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_complimentaryThis 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_nameThe status of bundle as a string (i.e. activecanceled, etc).
bundle_date_addedThe date the bundle was added to the member's account in the format YYYY-MM-DD HH:MM:SS.
bundle_last_updatedThe date the bundle was last updated on the member's account in the format YYYY-MM-DD HH:MM:SS.
Order Data
AttributeDescription
order_numberThe reference number assigned to the order by MemberMouse.
order_transaction_idThe 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_totalThe order total which equals (subtotal – discount) + shipping.
order_subtotalThe order subtotal.
order_discountThe discount applied to the order.
order_shippingShipping cost applied to the order.
order_shipping_methodThe name of the shipping method chosen by the customer when checking out.
order_billing_addressThe billing address associated with the order.
order_billing_cityThe billing city associated with the order.
order_billing_stateThe billing state associated with the order.
order_billing_zip_codeThe billing zip code associated with the order.
order_billing_countryThe billing country associated with the order.
order_shipping_addressThe shipping address associated with the order.
order_shipping_cityThe shipping city associated with the order.
order_shipping_stateThe shipping state associated with the order.
order_shipping_zip_codeThe shipping zip code associated with the order.
order_shipping_countryThe shipping country associated with the order.
order_productsAn array of products associated with the order. See the Product Data table below for parameters available for each product.
order_couponsAn array of coupons associated with the order. See the Coupon Data table below for parameters available for each coupon.
order_prorationsAn array of prorations associated with the order. See the Proration Data table below for parameters available for each proration item.
order_affiliate_idThe affiliate ID associated with the order.
order_subaffiliate_idThe subaffiliate ID associated with the order.
order_ip_addressThe IP Address associated with the order.
Affiliate Data
AttributeDescription
order_affiliate_idThe affiliate ID associated with the order.
order_subaffiliate_idThe subaffiliate ID associated with the order.
member_idThe ID assigned to the member by MemberMouse.
order_numberThe 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_totalThe order total available for commissions which equals the order total minus discounts and shipping costs.
order_ip_addressThe IP Address associated with the order.
order_productsAn array of products associated with the order. See the Product Data table below for parameters available for each product.
order_couponsAn array of coupons associated with the order. See the Coupon Data table below for parameters available for each coupon.
order_prorationsAn array of prorations associated with the order. See the Proration Data table below for parameters available for each proration item.
rebill_commission_flat_rateThis 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_percentThis 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.

AttributeDescription
idThe ID of the product.
nameThe name of the product.
skuThe SKU for the product.
amountThe amount paid for each unit of the product.
quantityThe number of this product purchased.
totalThe total price paid equivalent to amount * quantity.
is_recurringIndicates where this product has a subscription associated with it or not. Possible values are ‘true' or ‘false'.
recurring_amountThe amount paid each rebill period.
rebill_periodAn 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_frequencyAn 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.

AttributeDescription
idThe ID of the coupon.
nameThe name of the coupon.
codeThe 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.

AttributeDescription
amountThe amount of the proration.
descriptionThe description associated with the purchase.
Was this article helpful?

Related Articles