Developers - Action & Filter Reference

WooCommerce Membership comes with action & filter hooks that allow developers to extend its functionality. Below is a list of available actions and filters.

 

Action: woocommerce_membership_subscription_membership_ids

Allows subscription plugins to save IDs of Membership Plans associated with a particular Order Item which is also a subscription product.

Parameters: 

$order_item_id integer ID of WooCommerce Order Item
$plan_ids array IDs of Membership Plans associated with subscription product
$order_id integer ID of WooCommerce Order

 

Filter: woocommerce_membership_cancel_activation

Allows other plugins to cancel Membership activation. Defaults to false.

Parameters: 

$cancel bool Whether to cancel Membership activation
$order_id integer ID of WooCommerce Order
$item_id integer WooCommerce Order Item ID
$item array WooCommerce Order Item data
$product_id integer ID of WooCommerce Product or Product Variation

 

Filter: woocommerce_membership_cancel_deactivation

Allows other plugins to cancel Membership deactivation. Defaults to false.

Parameters: 

$cancel bool Whether to cancel Membership deactivation
$order_id integer ID of WooCommerce Order
$item_id integer WooCommerce Order Item ID
$item array WooCommerce Order Item data
$product_id integer ID of WooCommerce Product or Product Variation

 

 

Filter: woocommerce_membership_skip_post_type

Allows developers to skip custom post type. If skipped, WooCommerce Membership plugin will not affect this custom post type in any way (won't add content restriction boxes to the user interface etc). Defaults to false.

Parameters: 

$skip bool Whether to skip current post type
$post_type string Name of post type

 

Filter: woocommerce_membership_grant_access_roles

Roles that need full access to all (even restricted) content. Defaults to <code>array('administrator')</code>.

Parameters: 

$roles array List of roles that have access to all content

 

Filter: woocommerce_membership_display_shortcode_content

Allows developers to stop displaying shortcode-protected content that is about to be displayed or display content which is not being displayed because of restrictions.

Parameters: 

$display bool Whether to display content or not
$shortcode string Current shortcode name
$keys array List of keys that were passed to shortcode attributes
$content string Content that is about to be displayed

 

Filter: woocommerce_membership_subscription_support

Allows subscription (recurring payment) plugins to let this plugin know about their existence. Defaults to false.

Parameters: 

$subscription_support bool Whether subscription support should be enabled

 

Filter: woocommerce_membership_product_is_subscription

Allows subscription (recurring payment) plugins to tell which membership products are also subscription products. Defaults to false.

Parameters: 

$is_subscription bool Whether membership product is also a subscription product
$product_id integer WooCommerce Product or Product Variation ID

 

Filter: woocommerce_membership_user_capabilities

Extend list of capabilities assigned to a specific user. WooCommerce Membership uses this list to determine if user has required capabilities to access members-only content. Membership Plan keys are stored as user capabilities at the time when particular user purchases a membership product.

Parameters: 

$capabilities array List of WordPress capabilities
$user object WordPress User object

 

Filter: woocommerce_membership_capability

Override WordPress capability required to access plugin's settings. Defaults to 'manage_options'.

Parameters: 

$capability string Capability required to manage settings
$context string Currently only 'settings'

 

Filter: woocommerce_membership_date_format

Override WordPress date format (can be configured under Settings > General) that is used by this plugin to display dates. Must be in PHP date() format.

Parameters: 

$format string Date format
$context string Current context

 

Filter: woocommerce_membership_time_format

Override WordPress time format (can be configured under Settings > General) that is used by this plugin to display times. Must be in PHP date() format.

Parameters: 

$format string Time format
$context string Current context

 

Filter: woocommerce_membership_display_event_time

Whether to display times or not (if not, only dates will be displayed). Defaults to true.

Parameters: 

$display bool Whether to display time

 

 

 

 

 

 

 

Have more questions? Submit a request