1. Documentation /
  2. WooCommerce Memberships Frontend Hook Reference

WooCommerce Memberships Frontend Hook Reference

For Developers: Frontend Hook Reference

↑ Back to top
This 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 top
All 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
Filter the user cancelled membership message on frontend — defaults to, “Your membership was cancelled.”

wc_memberships_member_login_message

@since
1.3.8
@param
string $message The message text
@return
string – the updated message
Filter the member login notice message. This can be configured under settings as well, but we recommend using the default message and filtering as needed, as by default this message responds to the number of discounted items in the cart.

Filters: Restriction Messages

↑ Back to top
All 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
If you wanted to remove a restriction notice completely, you could use this filter to modify the message HTML or delete it. This example snippet shows its use for modifying the restricted content, so you could return the content without the restriction message, or modify the message and return the content as desired.

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
Filters the product viewing restricted 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
Filters the product purchasing restricted 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
Filters the content restricted 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
Filters the content delayed message. Example to show a custom delayed message for the “project” post type: https://github.com/godaddy-wordpress/wc-plugins-snippets/blob/master/woocommerce-memberships/frontend/change-content-delayed-access-message.php?footer=minimal

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
Filters the product category viewing restricted message. Defaults to, “This product category can only be viewed by members. To view this category, sign up by purchasing {products}, or log in if you are a member.” If no product purchases can grant access to the category, defaults to, “This product category can only be viewed by members.”

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
Filter the product term viewing delayed access message. Defaults to, “This product category is part of your membership, but not yet! You will gain access on {date}.”

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 the member discount message shown to non-members or non-logged in users.

Filters: Member Discounts

↑ Back to top

wc_memberships_member_prices_use_discount_format

@since
1.3.0
@param
bool $use_discount_format Defaults to true
located in: /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
located in: /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: $nonmember price $member price Returned True: $original price $sale price $member price Defaults to false — only shows sale price [if set] and member price, or original price and member price.

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
located in: /templates/loop/member-discount-badge.php Filters the Member Discount badge HTML.

Filters: My Memberships

↑ Back to top

wc_memberships_my_memberships_title

@since
1.5.0
@param
string $title My Memberships table title
@return
string – updated title
located in: /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
located in: /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
located in: /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
located in: /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 top

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
located in: /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
located in: /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 top
All 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
Filters the heading for the “My Content” section.

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
Filters the columns in the “My Content” section. If adding a column, be sure to also fill that column with content using the
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 top
All 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
Filters the heading for the “My Products” section.

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
Filters the columns in the “My Products” section. If adding a column, be sure to also fill that column with content using the
wc_memberships_members_area_my_membership_products_column_{$column_id}
action.

My Membership Discounts

↑ Back to top
All 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
Filters the heading for the “My Discounts” section. Example to change the heading to “Exclusive Discounts”.

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
Filters the columns in the “My Discounts” section. If adding a column, be sure to also fill that column with content using the
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
Filters whether the “My Discounts” area should list all discounts for the membership or only active discounts for the membership. Return false to show all discounts (including inactive discounts).

Membership Notes

↑ Back to top
All 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
Filters the heading for the “Membership Notes” section.

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
Filters the columns in the “My Membership Notes” section. If adding a column, be sure to also fill that column with content using the
wc_memberships_members_area_my_membership_notes_column_{$column_id}
action.

Actions: My Memberships

↑ Back to top
All “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
Fires when the column with $column_id is displayed in the My Memberships table. Used to fill a custom column with content.

wc_memberships_after_my_memberships

Fired after My Memberships table in My Account page.

Actions: Member Area

↑ Back to top

wc_memberships_before_members_area

@since
1.4.0
@param
string $section the section ID
Fires before each section of the member area.

wc_memberships_after_members_area

@since
1.4.0
@param
string $section the section ID
Fires after each section of the member area.

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
located in: /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
located in: /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
located in: /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
located in: /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 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
located in: /includes/admin/class-wc-memberships-admin-membership-plans.php Fires after a membership plan has been duplicated.

Table of Contents

↑ Back to top
All done here? Return to documentation overview →