Skip to content

Instantly share code, notes, and snippets.

@bekarice
Last active February 5, 2022 21:52
Show Gist options
  • Save bekarice/62cc848397fdedb02cfe to your computer and use it in GitHub Desktop.
Save bekarice/62cc848397fdedb02cfe to your computer and use it in GitHub Desktop.
Remove "My Memberships" table on My Account with WooCommerce Memberships
<?php // Only copy this line if needed
/**
* Removes the "My Memberships" table from my account area
*/
function sv_remove_my_memberships_table() {
if ( function_exists( 'wc_memberships' ) && ! is_admin() ) {
remove_action( 'woocommerce_before_my_account', array( wc_memberships()->get_frontend_instance()->get_members_area_instance(), 'my_account_memberships' ) );
}
}
add_action( 'init', 'sv_remove_my_memberships_table', 50 );
@Chunkford
Copy link

With the new version 1.9+ this no longer works.
Is there any other solution to removing the membership completely from the customer's myaccount area?
I control the customer's access to just one membership plan based on spend volume over a certain period. Having this information will only confuse the end user

@Chunkford
Copy link

Chunkford commented Nov 3, 2017

OK, I've mananged to achieve what I wanted.
If anyone else wants to hide the member's section in myaccount, replace the remove_action function with the following line of code:

remove_filter( 'woocommerce_account_menu_items', array( wc_memberships()->get_frontend_instance()->get_members_area_instance(), 'add_account_members_area_menu_item' ), 999 );

This will hide the member's area link so to stop it being accessed easily

@sbible
Copy link

sbible commented Apr 27, 2018

With 1.10.1 the original code took down my entire site. Modifying the snippet per @Chunkford's instructions resolved the issue. (Thanks @Chunkford!)

@abhivr
Copy link

abhivr commented Oct 18, 2019

The easiest way to do this without PHP is to go to Woocommerce > Settings > Advanced and then delete the text in the My Membership End Point.

It will remove the tab from the My Accounts Page.

image

@TomasHurtz
Copy link

TomasHurtz commented Mar 6, 2020

This works - thanks

// hide My Membership from the my account page
function just_remove_my_memberships_table() {
if ( function_exists( 'wc_memberships' ) && ! is_admin() ) {
remove_filter( 'woocommerce_account_menu_items', array( wc_memberships()->get_frontend_instance()->get_members_area_instance(), 'add_account_members_area_menu_item' ), 999 );
}
}
add_action( 'init', 'just_remove_my_memberships_table', 50 );

@BoyetDgte
Copy link

The easiest way to do this without PHP is to go to Woocommerce > Settings > Advanced and then delete the text in the My Membership End Point.

It will remove the tab from the My Accounts Page.

image

Why do we need the snippet when we have the settings :) Thanks Man!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment