Remove My Account Menu items in Woocommerce based on user roles
Question
I need to be able to unset or disable certain Myaccount menu items in Woocommerce Dashboard based on user role. So for example show “orders” menu for customers (role) and not show menu “orders” for subscribers (role). Not sure of the best way to do that. I use the code in plugin called “Code Snippets” in WordPress.
add_filter ( 'woocommerce_account_menu_items', 'silva_remove_my_account_links' );
function silva_remove_my_account_links( $menu_links ){
unset( $menu_links['downloads'] ); // Disable Downloads
// If you want to remove any of the other default links, just uncomment out the items below:
//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['edit-account'] ); // Remove Account details tab
//unset( $menu_links['customer-logout'] ); // Remove Logout link
return $menu_links;
}
0
2 months
2023-01-30T19:41:13-05:00
2023-01-30T19:41:13-05:00 0 Answers
0 views
0
Leave an answer