WooCommerce Memberships Snippet Samples

Here are some sample snippets helpful for tweaking the functionality of the WooCommerce Memberships plugin.

If you’re looking for more details on modifying Memberships or “For Developers” samples, please view our developer documentation.

Note that these snippets are UNSUPPORTED and are provided as a courtesy. We are unable to modify them or implement them on your site. If you’re not sure how to add custom code to your site or you want to modify these snippets, we recommend hiring an WooExpert to assist.

Member Area ↑ Back to top

Remove Cancel action from My Memberships table ↑ Back to top

The actions in the “My Memberships” table can be removed if you don’t want to allow your members to manage their own memberships. This snippet removes the “Cancel” action from the “My Memberships” table in the account area.

Note: Memberships automatically does this for you if a membership is tied to a subscription, forcing cancellation via the billing instead.

Remove End Date Column from My Memberships ↑ Back to top

Removes the “End Date” column from being displayed for all user memberships.

Remove Type Column from My Content Area ↑ Back to top

The “My Content” section of the Member Area will show the content type (Post, Page, Project, Forum, etc) as this paginated section shows all accessible content (posts, pages, custom post types) on the site. This snippet removes the “Type” column if its display isn’t needed.

Remove Description Column from My Products Area ↑ Back to top

The paginated “My Products” section of the Member Area will show all accessible products for the member (those the plan grants viewing / purchasing for). This snippet removes the “Description” / Excerpt column if its display isn’t needed.

Blog & Posts ↑ Back to top

Show Lock Icon on Restricted Posts ↑ Back to top

This snippet requires your site to have loaded FontAwesome already, as it uses the FontAwesome lock icon. It will show a lock next to the title of any post the member does not have access to yet, or any restricted posts for non-members.

Shop Pages ↑ Back to top

Remove Member Discount Badges ↑ Back to top

The member discount badge’s HTML is filterable, and therefore it can be removed completely using this snippet:

add_filter( 'wc_memberships_member_discount_badge', '__return_empty_string' );

Disable Discount Stacking ↑ Back to top

By default, Memberships will assume that members should always have all benefits of a membership plan. However, this could potentially result in a member receiving 2 discounts or more on a product if the member has multiple plans with discounts.

If you want to disable this behavior, Memberships can instead choose the best discount only instead of stacking discounts — add this snippet to do so:

add_filter( 'wc_memberships_allow_cumulative_member_discounts', '__return_false' );

Integrations ↑ Back to top

Add Social Login Buttons to Restriction Messages ↑ Back to top

You can add WooCommerce Social Login buttons into the “content restricted” notices to make it easier for members with a linked account to log in.

We do have this on our Memberships / Social Login roadmaps to add support for. Until this happens within the plugins themselves, you could add this code snippet to show login buttons in content restriction notices.

Other Snippets ↑ Back to top

Grant Access only from Completed Orders ↑ Back to top

By default, Memberships grants access to customers for any processing or completed order on your site since these represent paid orders. If you’d like access to only be granted when an order is ‘completed’, but not while it’s ‘processing’, you can use this snippet:

If you want to add statuses (such as custom statuses) that grant access, our developer documentation can help.

Create My Memberships Shortcode ↑ Back to top

If you want to output the “My Memberships” table outside of the “My Account” area, you can create a shortcode to do so. Please have a look at this snippet.

More Snippets ↑ Back to top

We keep a collection of team snippets for our plugins in this repository. However, the same policy applies — we cannot support these snippets, assist with implementation, or assist with further customizations.

Table of Contents ↑ Back to top

All done here? Return to documentation overview →


Note that these snippets are UNSUPPORTED and are provided as a courtesy. We are unable to modify them or implement them on your site. If you’re not sure how to add custom code to your site or you want to modify these snippets, we recommend hiring an Woo Expert to assist.

WooCommerce - the most customizable eCommerce platform for building your online business.

Back to the top