For Developers: Frontend Hook Reference
↑ Back to topThis document covers all frontend-specific hooks in WooCommerce Memberships. You can also view the document on admin-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: Member Messages
↑ Back to topAll filters for member messages are located in: /includes/frontend/class-wc-memberships-frontend.php
wc_memberships_user_membership_cancelled_notice
- @since
- 1.0.0
- @param
- string $notice
- @return
- string – updated notice
wc_memberships_member_login_message
- @since
- 1.3.8
- @param
- string $message The message text
- @return
- string – the updated message
Filters: Restriction Messages
↑ Back to topAll frontend filters are included in: /includes/frontend/class-wc-memberships-frontend.php
wc_memberships_the_restricted_content
- @since
- 1.6.0
- @param
- string $content HTML content displayed for the post
- @param
- bool $restricted Whether the content is restricted
- @param
- string $message The restriction message applied, could be empty string
- @param
- \WP_Post $post The post being restricted
- @return
- string – the updated restricted content HTML
wc_memberships_product_viewing_restricted_message
- @since
- 1.0.0
- @param
- string $message The restriction message
- @param
- int $product_id ID of the product being restricted
- @param
- array $products Array of product IDs that grant access to this product
- @return
- string – the updated restriction message
wc_memberships_product_purchasing_restricted_message
- @since
- 1.0.0
- @param
- string $message The restriction message
- @param
- int $product_id ID of the product being restricted
- @param
- array $products Array of product IDs that grant access to this product
- @return
- string – the updated restriction message
wc_memberships_content_restricted_message
- @since
- 1.0.0
- @param
- string $message The restriction message
- @param
- int $post_id ID of the product being restricted
- @param
- array $products Array of product IDs that grant access to this product
- @return
- string – the updated restriction message
wc_memberships_get_content_delayed_message
- @since
- 1.3.1
- @param
- string $message Delayed content message
- @param
- int $post_id Post ID that the message applies to
- @param
- string $access_time Access time timestamp
- @return
- string – the updated restriction message
wc_memberships_product_taxonomy_viewing_restricted_message
- @since
- 1.4.0
- @param
- string $message The restriction message
- @param
- string $taxonomy Product taxonomy
- @param
- int $term_id Product taxonomy term id
- @param
- array $products Array of product IDs that grant access to products taxonomy
- @return
- string – the updated restriction message
wc_memberships_product_term_viewing_delayed_message
- @since
- 1.4.0
- @param
- string $message The delayed access message
- @param
- string $taxonomy Product taxonomy
- @param
- int $term_id Product taxonomy term id
- @return
- string – the updated restriction message
wc_memberships_member_discount_message
- @since
- 1.0.0
- @param
- string $message The discount message
- @param
- int $product_id ID of the product that has member discounts
- @param
- array $products Array of product IDs that grant access to this product
- @return
- string – the updated discount message
Filters: Member Discounts
↑ Back to topwc_memberships_member_prices_use_discount_format
- @since
- 1.3.0
- @param
- bool $use_discount_format Defaults to true
/includes/class-wc-memberships-member-discounts.php
Controls whether or not member prices should use discount format when displayed. If returned false, discounted prices will be shown without the original price. Defaults to true.
wc_memberships_member_prices_display_sale_price
- @since
- 1.3.0
- @param
- bool $display_sale_price Defaults to false
/includes/class-wc-memberships-member-discounts.php
Controls whether or not member prices should display sale prices as well. If returned true, the original price, sale price, and member price will be shown.
Default: wc_memberships_member_discount_badge
- @since
- 1.0.0
- @param
- string $badge_html the member discount badge HTML
- @param
- \WP_Post $post Post object
- @param
- \WC_Product $product Product object
- @return
- string – updated badge HTML
/templates/loop/member-discount-badge.php
Filters the Member Discount badge HTML.
Filters: My Memberships
↑ Back to topwc_memberships_my_memberships_title
- @since
- 1.5.0
- @param
- string $title My Memberships table title
- @return
- string – updated title
/templates/myaccount/my-memberships.php
Filters the title of the My Memberships table. Defaults to “My Memberships”.
wc_memberships_my_memberships_column_names
- @since
- 1.4.0
- @param
- array $my_memberships_columns Associative array of column ids and names
- @param
- int $user_id ID of logged in user
- @return
- array – updated array of columns
/templates/myaccount/my-memberships.php
Filters the My Memberships table columns in My Account page. Example: remove “end date” column:
https://github.com/godaddy-wordpress/wc-plugins-snippets/blob/master/woocommerce-memberships/frontend/remove-my-memberships-end-date-column.php?footer=minimal
wc_memberships_get_renew_membership_url
- @since
- 1.0.0
- @param
- string $url renewal URL
- @param
- WC_Memberships_User_Membership $user_membership
- @return
- string – updated URL
/includes/class-wc-memberships-user-membership.php
Filters the renewal URL for a membership. Helpful if you want to change the renewal URL / button to “upgrade” a membership.
Example: Renew trial plan by purchasing an upgrade.
wc_memberships_get_cancel_membership_url
- @since
- 1.0.0
- @param
- string $url cancellation URL
- @param
- WC_Memberships_User_Membership $user_membership
- @return
- string – updated URL
/includes/class-wc-memberships-user-membership.php
Filters the cancel URL for a membership. Not needed for memberships purchased via subscription, as the button is hidden.
Filters: Member Area
↑ Back to topWe have an overview of customizing the member area and adding custom sections.
wc_membership_plan_members_area_sections
- @since
- 1.4.0
- @param
- array $member_area_sections Associative array with member area id and label of each section
- @param
- int|string $membership_plan Optional, the current membership plan, might be empty
- @return
- array – updated array of sections
/includes/wc-memberships-membership-plan-functions.php
Filters the available choices for the members area sections of a membership plan.
Example: Rename the section links:
https://github.com/godaddy-wordpress/wc-plugins-snippets/blob/master/woocommerce-memberships/frontend/member-area/rename-member-area-section-links.php?footer=minimal
wc_memberships_members_area_{$section}_actions
- @since
- 1.4.0
- @param
- array $default_actions Associative array of actions
- @param
- \WC_Memberships_User_Membership $user_membership User Membership object
- @param
- \WC_Product|\WP_Post|object $object Current object where the action is run (optional)
- @return
- array – updated array of actions
/includes/wc-memberships-template-functions.php
Filter membership actions on My Account and Members Area pages. The $section is the member area section, e.g., ‘my-membership’, ‘my-membership-content’, etc.
Example: Remove “Cancel” button.
My Membership Content
↑ Back to topAll hooks for the “My Content” section of the Member Area are located in the template file: /templates/myaccount/my-membership-content.php
wc_memberships_members_area_my_membership_content_title
- @since
- 1.4.0
- @param
- string $title the section title
- @return
- string – the updated title
wc_memberships_members_area_my_membership_content_column_names
- @since
- 1.4.0
- @param
- array $columns Associative array of column ids and names
- @param
- int $user_id ID of logged in user
- @return
- array – updated array of columns
wc_memberships_members_area_my_membership_content_column_{$column_id}action. Example to add an “Author” column: https://github.com/godaddy-wordpress/wc-plugins-snippets/blob/master/woocommerce-memberships/frontend/member-area/add-author-column-to-my-content.php?footer=minimal You could also remove columns: example to remove “Type” column
My Membership Products
↑ Back to topAll hooks for the “My Products” section of the Member Area are located in the template file: /templates/myaccount/my-membership-products.php
wc_memberships_members_area_my_membership_products_title
- @since
- 1.4.0
- @param
- string $title the section title
- @return
- string – the updated title
wc_memberships_members_area_my_membership_products_column_names
- @since
- 1.4.0
- @param
- array $columns Associative array of column ids and names
- @param
- int $user_id ID of logged in user
- @return
- array – updated array of columns
wc_memberships_members_area_my_membership_products_column_{$column_id}action.
My Membership Discounts
↑ Back to topAll hooks for the “My Discounts” section of the Member Area are located in the template file: /templates/myaccount/my-membership-discounts.php
wc_memberships_members_area_my_membership_discounts_title
- @since
- 1.4.0
- @param
- string $title the section title
- @return
- string – the updated title
wc_memberships_members_area_my_membership_discounts_column_names
- @since
- 1.4.0
- @param
- array $columns Associative array of column ids and names
- @param
- int $user_id ID of logged in user
- @return
- array – updated array of columns
wc_memberships_members_area_my_membership_discounts_column_{$column_id}action.
wc_memberships_members_area_show_only_active_discounts
- @since
- 1.4.0
- @param
- bool $show_only_active_discounts Default true
- @param
- int $user_id ID of logged in user
- @param
- int $product_id ID of discounted product
Membership Notes
↑ Back to topAll hooks for the “My Discounts” section of the Member Area are located in the template file: /templates/myaccount/my-membership-notes.php
wc_memberships_members_area_my_membership_notes_title
- @since
- 1.4.0
- @param
- string $title the section title
- @return
- string – the updated title
wc_memberships_members_area_my_membership_notes_column_names
- @since
- 1.4.0
- @param
- array $columns Associative array of column ids and names
- @param
- int $user_id ID of logged in user
- @return
- array – updated array of columns
wc_memberships_members_area_my_membership_notes_column_{$column_id}action.
Actions: My Memberships
↑ Back to topAll “My Memberships” actions are located in: /templates/myaccount/my-memberships.php
wc_memberships_before_my_memberships
Fired before My Memberships table in My Account page.wc_memberships_my_memberships_column_{$column_id}
- @since
- 1.4.3
- @param
- \WC_Memberships_User_Membership $user_membership
wc_memberships_after_my_memberships
Fired after My Memberships table in My Account page.Actions: Member Area
↑ Back to topWe have an overview of customizing the member area and adding custom sections.
wc_memberships_before_members_area
- @since
- 1.4.0
- @param
- string $section the section ID
wc_memberships_after_members_area
- @since
- 1.4.0
- @param
- string $section the section ID
wc_memberships_members_area_my_membership_content_column_{$column_id}
- @since
- 1.4.0
- @param
- \WP_Post $post the post object for which the row’s data is shown
/templates/myaccount/my-membership-content.php
Fired for any “My Content” column added with a custom ID. Fills the table cell with content for this column. See this example.
wc_memberships_members_area_my_membership_products_column_{$column_id}
- @since
- 1.4.0
- @param
- \WC_Product $product the product object for which the row’s data is shown
/templates/myaccount/my-membership-products.php
Fired for any “My Products” column added with a custom ID. Fills the table cell with content for this column.
wc_memberships_members_area_my_membership_discounts_column_{$column_id}
- @since
- 1.4.0
- @param
- \WC_Product $product the product object for which the row’s data is shown
/templates/myaccount/my-membership-discounts.php
Fired for any “My Discounts” column added with a custom ID. Fills the table cell with content for this column.
wc_memberships_members_area_my_membership_notes_column_{$column_id}
- @since
- 1.4.0
- @param
- object $note the membership note comment object for the row
/templates/myaccount/my-membership-notes.php
Fired for any “My Membership Notes” column added with a custom ID. Fills the table cell with content for this column.
Actions: General
↑ Back to topwc_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
/includes/admin/class-wc-memberships-admin-membership-plans.php
Fires after a membership plan has been duplicated.