Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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 );
@stuartduff

This comment has been minimized.

Copy link

stuartduff commented Jun 8, 2016

@bekarice With the latest version of Memberships v1.6.0 and above the remove action has now changed and the method above is depreciated but referenced from our documentation pages.

@SMEIP

This comment has been minimized.

Copy link

SMEIP commented Jul 9, 2016

hi, i'm trying to remove "My Memberships" table on My Account , i used the code below but it still show "My Memberships" table on My Account page :( is there any other solution for this problem ??? thnx for heelping me
WooCommerce Memberships Version 1.6.2
merci beaucoup

@davidmcc3

This comment has been minimized.

Copy link

davidmcc3 commented Jul 13, 2016

I had this working, but now I've updated WooCommerce and Memberships, the table has re-appeared.

What is the new code to replace this?

I can't find anything on Skyverge or WooThemes for this.

@gvargas9

This comment has been minimized.

Copy link

gvargas9 commented Oct 13, 2016

I think the code is broken Fatal error: Call to undefined method WC_Memberships::get_frontend_instance() in ....functions.php on line 54

@markob17

This comment has been minimized.

Copy link

markob17 commented Oct 14, 2016

Wanted to inform that this is working for me. Am using Woocommerce latest version, Woocommerce subscriptions and memberships latest versions as well.

@iplaywind

This comment has been minimized.

Copy link

iplaywind commented Feb 26, 2017

hi, I add this code to theme's function.php, but get the following error code in frontend.
Fatal error: Call to undefined method WC_Memberships_Frontend::get_members_area_instance in /data/.../wp-content/plugins/woocommerce-memberships/includes/frontend/class-wc-memberships-frontend.php on line 1055
Wordpress: 4.7.2
Woocommerce:2.6.8
WooCommerce Memberships: 1.7.3

@chickwithbob

This comment has been minimized.

Copy link

chickwithbob commented Jun 30, 2017

This is working for me in
WordPress 4.8
WooCommerce: 3.1.0
WooCommerce Memberships: 1.8.5

@Chunkford

This comment has been minimized.

Copy link

Chunkford commented Nov 3, 2017

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

This comment has been minimized.

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

This comment has been minimized.

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

This comment has been minimized.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.