Add Menu or Remove Menu Link on Woocommerce My Account Page

This tutorial is rarely found on the Search Engine that is why we made a quick guide how you can actually customize your MY ACCOUNT Page of your Woocommerce websites such as Remove Menu or Add Menu with Links using only the functions.php file, so it means no plugin involves, it is useful especially when your client wanted you to add a specific menu that is why we have this tutorial for you.
As you can see on the video it has a quick explanation of how to use the code, so just follow the tutorial video above made by Kazuki Tech and then just copy the code we have included here.

How To Remove Menu on My Account?
add_filter ( 'woocommerce_account_menu_items', 'misha_remove_my_account_links' );
function misha_remove_my_account_links( $menu_links ){

unset( $menu_links['edit-address'] ); // Addresses


//unset( $menu_links['dashboard'] ); // Remove Dashboard
//unset( $menu_links['payment-methods'] ); // Remove Payment Methods
//unset( $menu_links['orders'] ); // Remove Orders
//unset( $menu_links['downloads'] ); // Disable Downloads
//unset( $menu_links['edit-account'] ); // Remove Account details tab
//unset( $menu_links['customer-logout'] ); // Remove Logout link

return $menu_links;

}

Just uncomment the code in which you want to remove a specific tab menu on your my-account page.

Related Articles:


How To Rename The Menu Tabs for My Account Page?
add_filter ( 'woocommerce_account_menu_items', 'misha_rename_downloads' );

function misha_rename_downloads( $menu_links ){

// $menu_links['TAB ID HERE'] = 'NEW TAB NAME HERE';
$menu_links['downloads'] = 'My Files';

return $menu_links;

}

TAB ID HERE: you just replace that to a constant id menu which is listed below.

  • dashboard
  • payment-methods
  • orders
  • downloads
  • edit-account
  • customer-logout
NEW TAB NAME HERE: This is where your custom tab menu, replace this one with your own tab menu name.

How You Can Rename Tabs Menu in My Account
Add A Custom URLs for Menu in My Account Page


add_filter ( 'woocommerce_account_menu_items', 'misha_one_more_link' );
function misha_one_more_link( $menu_links ){
 
// we will hook "anyuniquetext123" later
$new = array( 'anyuniquetext123' => 'Gift for you' );
 
// or in case you need 2 links
// $new = array( 'link1' => 'Link 1', 'link2' => 'Link 2' );
 
// array_slice() is good when you want to add an element between the other ones
$menu_links = array_slice( $menu_links, 0, 1, true ) 
+ $new 
+ array_slice( $menu_links, 1, NULL, true );
 
 
return $menu_links;
 
 
}
 
add_filter( 'woocommerce_get_endpoint_url', 'misha_hook_endpoint', 10, 4 );
function misha_hook_endpoint( $url, $endpoint, $value, $permalink ){
 
if( $endpoint === 'anyuniquetext123' ) {
 
// ok, here is the place for your custom URL, it could be external
$url = site_url();
 
}
return $url;
 
}

anyuniquetext123: Replace it with your custom link for example blog/, contact/, services/ etc.

Source: RudRustyH

Comments

Popular posts from this blog

Summertime Saga SAVE Data (Full Unlock) for Android & PC - All Versions

How To Live Stream on Facebook Page or Facebook Account Timeline?

Mocha Uson Interview with DFA Sec. Alan Peter Cayetano (Kahit Wala Na Sa Gobyerno Tuloy Parin Tayo)