WooCommerce Memberships Admin Hook Reference

For Developers: Admin Hook Reference

↑ Back to top
This document covers all admin-specific hooks in WooCommerce Memberships. You can also view the document on frontend-specific hooks.
WooCommerce Memberships is extremely extensible and offers ample actions and filters for developers to customize it as needed. If a hook doesn’t exist where you think it should, please submit a ticket so we can consider its addition. This hook reference includes some of the actions and filters developers may find useful while customizing the plugin, but is not an exhaustive reference of all plugin hooks. Inline docs include parameters and returned values for more detail — the appropriate file for each hook is listed so you can refer to it.
Please note that this document is a developer reference provided as a courtesy, as our support policy does not include customizations. This reference lists helpful filters / actions and is meant to be a directory. Please see the plugin’s inline documentation for additional details on parameters, returned values, and usage.

Filters: Membership Access

↑ Back to top

wc_memberships_access_granting_purchased_product_id

@since
1.0.0
@param
int $product_id the ID that’s used for access
@param
array $access_granting_product_ids Array of product IDs that can grant access to this plan
@param
\WC_Memberships_Membership_Plan $plan Membership plan access will be granted to
@return
int – the new product ID to use
Multiple products from a single order can grant access to a membership plan. Default behavior is to use the first product that grants access, but this can be overridden using this filter.

wc_memberships_grant_access_from_new_purchase

@since
1.3.5
@param
bool $grant_access true by default
@param
array $args {
  • @type int|string $user_id user ID for order
  • @type int|string $product_id product ID that grants access
  • @type int|string $order_id order ID
  • }
Filters whether membership access should be granted from the current purchase or not. Default behavior is to always grant access if a membership product is purchased.

Examples:

wc_memberships_plan_grants_access_while_subscription_active

@since
1.6.0
@param
bool $grants_access Default: true
@param
int $plan_id Membership Plan ID
Filter whether a plan grants access to a membership while subscription is active.

wc_memberships_grant_access_from_existing_purchase_order_statuses

@since
1.0.0
@param
array $valid_order_statuses_for_grant array of order statuses
@param
object $plan the associated membership plan object
@return
array – the updated array of status
Filter the array of valid order statuses that grant access from previous purchases when the admin uses the “grant previous purchases access” action. Defaults to ‘processing’ and ‘completed’. Example to add “Shipped” and “Invoice Paid” orders (You could also use these statuses for access during the purchasing cycle in addition to processing and completed orders, which the second function covers): https://gist-it.appspot.com/github/skyverge/wc-plugins-snippets/blob/master/woocommerce-memberships/admin/grant-membership-access-for-custom-order-statuses.php?footer=minimal

wc_memberships_allow_cumulative_member_discounts

@since
1.7.0
@param
bool $cumulative true if discounts should stack across plans
@param
int $member_id ID for the member / WP user
@param
\WC_Product $product
Filters whether discounts should stack if a member has more than one member discount for a product. Return false to disable stacking:
add_filter( 'wc_memberships_allow_cumulative_member_discounts', '__return_false' );

Filters: Membership Statuses

↑ Back to top

wc_memberships_user_membership_statuses

@since
1.0.0
@param
array $statuses Associative array of statuses
@return
array – updated status array
Passes in an associative array of all user membership statuses, which can be used to add custom user membership statuses. Example to add new statuses: https://gist-it.appspot.com/github/skyverge/wc-plugins-snippets/blob/master/woocommerce-memberships/admin/add-membership-status.php?footer=minimal

wc_memberships_active_access_membership_statuses

@since
1.7.0
@param
array $statuses array of statuses valid for content access
Filters the user memberships status that will give the customer access to restricted content.

wc_memberships_valid_membership_statuses_for_cancel

@since
1.0.0
@param
array $statuses Array of statuses valid for cancellation
@return
array – updated array of statuses
Filters the user membership statuses that can be cancelled by the customer.

wc_memberships_valid_membership_statuses_for_renewal

@since
1.0.0
@param
array $statuses Array of statuses valid for renewal
@return
array – updated array of statuses
Filters the user membership statuses that can be renewed by the customer.

wc_memberships_bulk_edit_user_memberships_status_options

@since
1.0.0
@param
array $statuses Array of bulk-edit statuses available
@return
array – updated array of statuses
Filter the status options available in user memberships bulk edit box.

Filters: Settings

↑ Back to top

wc_memberships_general_settings

@since
1.0.0
@param
array $settings Array of the plugin settings
@return
array – updated settings array
Filters the Memberships > General Settings.

wc_memberships_products_settings

@since
1.0.0
@param
array $settings Array of the plugin settings
@return
array – updated settings array
Filters the Memberships > Products Settings.

Filters: Excluded from Restriction

↑ Back to top

wc_memberships_content_restriction_excluded_post_types

@since
1.0.0
@param
array $post_types List of post types to exclude
@return
array – the updated array of post types
Creates a blocked list to exclude post types from content restriction content type options. Helpful if CPTs are added from other plugins that shouldn’t be available in content restriction rules. Example to remove Sensei Messages from posts that can be restricted: https://gist-it.appspot.com/github/skyverge/wc-plugins-snippets/blob/master/woocommerce-memberships/admin/exclude-post-type-from-content-restriction-options.php?footer=minimal

wc_memberships_{$rule_type}_excluded_taxonomies

@since
1.0.0
@param
array $taxonomies List of taxonomies to exclude
@return
array – updated taxonomy list
Excludes taxonomies from restriction rules. Rule type can be content_restriction, product_restriction, or purchasing_discount.

Filters: Meta Boxes

↑ Back to top

wc_memberships_product_data_tabs

@since
1.0.0
@param
array $tabs Associative array of memberships data tabs
@return
array – updated tab array
Filters product memberships data tabs in the Membership meta box to add or remove tabs.

wc_membership_plan_data_tabs

@since
1.0.0
@param
array $tabs Associative array of membership plan tabs
@return
array – updated tab array
Filters membership plan data tabs on the edit membership plan pages.

Actions: General

↑ Back to top

wc_memberships_activated

Runs when Memberships is activated.

wc_memberships_deactivated

Runs when Memberships is deactivated.

wc_memberships_duplicate_membership_plan

@since
1.0.0
@param
int $new_id New plan ID
@param
\WP_Post $post Original plan object
Fires after a membership plan has been duplicated.

Actions: Edit User Memberships

↑ Back to top

wc_memberships_before_user_membership_notes

@since
1.0.0
@param
WC_Memberships_User_Membership $user_membership The user membership
Fires at the beginning of the user membership notes meta box.

wc_memberships_after_user_membership_notes

@since
1.0.0
@param
\WC_Memberships_User_Membership $user_membership The user membership
Fires at the end of the user membership notes meta box.

wc_memberships_before_user_membership_member_details

@since
1.0.0
@param
int $user_id The member (user) ID
@param
int $user_membership_id The post id of the user membership post
Fires at the beginning of the member details meta box.

wc_memberships_after_user_membership_member_details

@since
1.0.0
@param
int $user_id The member (user) ID
@param
int $user_membership_id The post id of the user membership post
Fires at the end of the member details meta box.

wc_memberships_before_user_membership_details

@since
1.0.0
@param
\WC_Memberships_User_Membership $user_membership The user membership
Fires before the membership details in edit user membership screen.

wc_memberships_after_user_membership_details

@since
1.0.0
@param
\WC_Memberships_User_Membership $user_membership The user membership
Fires after the membership details in edit user membership screen.

wc_memberships_before_user_membership_billing_details

@since
1.0.0
@param
\WC_Memberships_User_Membership $user_membership The user membership
Fires before the billing details in edit user membership screen.

wc_memberships_after_user_membership_billing_details

@since
1.0.0
@param
\WC_Memberships_User_Membership $user_membership The user membership
Fires after the billing details in edit user membership screen.

wc_memberships_user_membership_actions_start

@since
1.0.0
@param
int $post_id The post id of the wc_user_membership post
Fires at the start of the user membership actions meta box.

wc_memberships_user_membership_actions_end

@since
1.0.0
@param
int $post_id The post id of the wc_user_membership post
Fires at the end of the user membership actions meta box.

Actions: Restriction Meta Boxes

↑ Back to top
All restriction meta box actions are located in: /includes/admin/meta-boxes/class-wc-memberships-meta-box-product-memberships-data.php

wc_memberships_data_product_write_panel_tabs

Fires after the product memberships data write panel tabs are displayed.

wc_memberships_data_options_restrict_product

Fires after the product memberships data product restriction panel is displayed.

wc_memberships_data_options_grant_access

Fires after the product memberships data grant access panel is displayed.

wc_memberships_data_options_purchasing_discounts

Fires after the membership plan purchasing discounts panel is displayed.

wc_memberships_data_product_panels

Fires after the product memberships data panels are displayed.

Actions: Edit Membership Plan

↑ Back to top
All membership plan page actions are located in: /includes/admin/meta-boxes/class-wc-memberships-meta-box-membership-plan-data.php

wc_membership_plan_write_panel_tabs

Fires after the membership plan write panel tabs are displayed.

wc_membership_plan_options_membership_plan_data_general

Fires after the membership plan general data panel is displayed.

wc_membership_plan_options_membership_plan_data_restrict_content

Fires after the membership plan content restriction panel is displayed.

wc_membership_plan_options_membership_plan_data_restrict_products

Fires after the membership plan product restriction panel is displayed.

wc_membership_plan_options_membership_plan_data_purchasing_discounts

Fires after the membership plan purchasing discounts panel is displayed.

wc_membership_plan_options_membership_plan_members_area

Fires after the membership plan members area panel is displayed.

wc_membership_plan_data_panels

Fires after the membership plan data panels are displayed.

Actions: Membership Lifecycle

↑ Back to top

wc_memberships_grant_membership_access_from_purchase

@since
1.0.0
@param
\WC_Memberships_Membership_Plan $membership_plan The plan that user was granted access to
@param
array $args {
  • @type int|string $user_id user ID for order
  • @type int|string $product_id product ID that grants access
  • @type int|string $order_id order ID
  • @type int|string $user_membership_id post ID for the new user membership
  • }
Fires after a user has been granted membership access from a purchase.

wc_memberships_user_membership_saved

@since
1.3.8
@param
/WC_Memberships_Membership_Plan $membership_plan The plan that user was granted access to
@param
array $args {
  • @type int|string $user_id user ID for the membership
  • @type int|string $user_membership_id post ID for the new user membership
  • @type bool $is_update true if the membership is being updated, false if new
  • }
Fires after a user has been granted membership access, either from purchase, from programmatically creating memberships, or from admin action.

wc_memberships_user_membership_created

@since
1.3.8
@param
/WC_Memberships_Membership_Plan $membership_plan The plan that user was granted access to
@param
array $args {
  • @type int|string $user_id user ID for the membership
  • @type int|string $user_membership_id post ID for the new user membership
  • @type bool $is_update true if the membership is being updated, false if new
  • }
Fires after a user has been granted membership access. This action hook is similar to wc_memberships_user_membership_saved, but won’t fire when memberships are manually created from admin.

wc_memberships_cancelled_user_membership

@since
1.0.0
@param
int $user_membership_id
Fires right after a user membership has been cancelled by the customer.

wc_memberships_user_membership_status_changed

@since
1.0.0
@param
WC_Memberships_User_Membership $user_membership
@param
string $old_status Old status, without the wcm- prefix
@param
string $new_status New status, without the wcm- prefix
Fires when user membership status is updated. Here’s an example of a basic handler to change user roles based on active / inactive membership status.

wc_memberships_new_user_membership_note

@since
1.0.0
@param
array $data {
  • @type int|string $user_membership_id post ID for the new user membership
  • @type object $note the user membership note (comment object) added
  • @type bool $notify true if the member will be notified
  • }
Fires after a new membership note is added.

User Documentation

↑ Back to top
All done here? Return to documentation overview →
Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.