1

I don't need the dashboard tab in woocommerce account page. So, how can I remove the Dashboard button from the menu in my account page - WooCommerce?

0

1 Answer 1

1

This requires 2 different hooked functions:

  • The first function will remove the first my account menu item (which is the dashboard).
  • The second function will redirect the default my account dashboard page to the first my account endpoint.

The code:

// Remove the first menu item (the dashboard)
add_filter( 'woocommerce_account_menu_items', 'account_menu_items_callback' );
function account_menu_items_callback( $items ) {
    foreach( $items as $key => $item ) {
        unset($items[$key]);
        break;
    }
    return $items;
}

// Redirect default my account dashboard to the first my account enpoint (after dashboard)
add_action( 'template_redirect', 'template_redirect_callback' );
function template_redirect_callback() {
    if( is_account_page() && is_user_logged_in() && ! is_wc_endpoint_url() ){
        $first_myaccount_endpoint = 'orders';
        wp_redirect( wc_get_account_endpoint_url( $first_myaccount_endpoint ) );
    }
}

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.