As you know, once you log in and go to My Account, WooCommerce displays the “Dashboard” tab content (also called the Dashboard “endpoint”). The Dashboard tab features the default “Hello Rodolfo Melogli (not Rodolfo Melogli? Log out) From your account dashboard you can view your recent orders, manage your shipping and billing addresses, and edit your password and account details.” message.
Now, what if we want to set another My Account tab as the default one upon login, for example the “Orders” one, or the “Downloads” one for a digital downloads WooCommerce business? Well, there are a couple of quick and not-so-quick solutions, enjoy!
PHP Snippet 1: Redirect Users to Another My Account Tab
By redirecting to another tab when people visit the “Dashboard” one, we’re simply saying that we wish to hide the whole Dashboard tab content. You will also need to remove the Dashboard tab from the My Account menu.
/**
* @snippet Redirect to new default tab @ WooCommerce My Account
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_action( 'template_redirect', 'bbloomer_my_account_redirect_to_downloads' );
function bbloomer_my_account_redirect_to_downloads(){
if ( is_account_page() && empty( WC()->query->get_current_endpoint() ) ) {
wp_safe_redirect( wc_get_account_endpoint_url( 'orders' ) );
exit;
}
}
In this case we’ve picked the “orders” tab. You can find other WooCommerce My Account tab IDs by looking at this other post.
PHP Snippet 2: Set Another My Account Tab as Default (But Keep The Dashboard)
You may not want to hide the Dashboard tab at all, and simply set another as the default tab. In this case, we can’t use the redirect snippet, as otherwise the Dashboard will never show.
Unfortunately, as of today, there is no clean solution (even if you reorder My Account tabs, the Dashboard tab content will show on load) – we need to find a workaround.
This workaround:
- replaces the “Dashboard” tab content to the tab content of your choice (e.g. “Downloads” tab content)
- renames the “Dashboard” tab title to whatever you want (“Downloads” in our example)
- hides the original “Downloads” tab as we already have it now
- readds the “Dashboard” tab as first tab together with its content
Part 1 – Replace Dashboard tab content with Downloads tab content
Please note woocommerce_account_downloads() is the function responsible to output the Downloads tab. You can find the other tabs’ content in this other tutorial.
/**
* @snippet Replace tab content @ WooCommerce My Account
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_action( 'woocommerce_account_content', 'bbloomer_myaccount_replace_dashboard_content', 1 );
function bbloomer_myaccount_replace_dashboard_content() {
remove_action( 'woocommerce_account_content', 'woocommerce_account_content', 10 );
add_action( 'woocommerce_account_content', 'bbloomer_account_content' );
}
function bbloomer_account_content() {
global $wp;
if ( empty( $query_vars = $wp->query_vars ) || ( ! empty( $query_vars ) && ! empty( $query_vars['pagename'] ) ) ) {
woocommerce_account_downloads();
} else {
foreach ( $wp->query_vars as $key => $value ) {
if ( 'pagename' === $key ) {
continue;
}
if ( has_action( 'woocommerce_account_' . $key . '_endpoint' ) ) {
do_action( 'woocommerce_account_' . $key . '_endpoint', $value );
return;
}
}
}
}
Part 2 – Rename Dashboard tab title to Downloads
/**
* @snippet Rename tab @ WooCommerce My Account
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_account_menu_items', 'bbloomer_myaccount_rename_dashboard_tab_title', 9999 );
function bbloomer_myaccount_rename_dashboard_tab_title( $items ) {
$items['dashboard'] = 'Downloads';
return $items;
}
Part 3 – Remove original Downloads tab
/**
* @snippet Remove tab @ WooCommerce My Account
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_account_menu_items', 'bbloomer_myaccount_remove_orders_tab', 9999 );
function bbloomer_myaccount_remove_orders_tab( $items ) {
unset( $items['downloads'] );
return $items;
}
Part 4 – Readd Dashboard tab
Note: you must resave the WordPress permalinks once the snippet is active.
/**
* @snippet Readd Dashboard tab @ WooCommerce My Account
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 6
* @community https://businessbloomer.com/club/
*/
add_action( 'init', 'bbloomer_myaccount_add_dashboard_endpoint' );
function bbloomer_myaccount_add_dashboard_endpoint() {
add_rewrite_endpoint( 'mydashboard', EP_ROOT | EP_PAGES );
}
add_filter( 'query_vars', 'bbloomer_query_vars', 0 );
function bbloomer_query_vars( $vars ) {
$vars[] = 'mydashboard';
return $vars;
}
add_filter( 'woocommerce_account_menu_items', 'bbloomer_add_new_dashboard_to_my_account' );
function bbloomer_add_new_dashboard_to_my_account( $items ) {
$items = array( 'mydashboard' => 'Dashboard' ) + $items;
return $items;
}