Open My Account on the Orders Page
Sends customers straight to their order list when they open My Account and removes the mostly empty Dashboard tab.
Opens WPIDE on
Code
$wpide_account_landing = 'orders'; // Endpoint to open.
add_filter( 'woocommerce_account_menu_items', function ( $items ) {
unset( $items['dashboard'] );
return $items;
} );
add_action( 'template_redirect', function () use ( $wpide_account_landing ) {
if ( ! is_user_logged_in() || ! is_account_page() || is_wc_endpoint_url() ) {
return;
}
global $wp;
if ( empty( $wp->query_vars ) || array_intersect_key( $wp->query_vars, array_flip( array( 'pagename', 'page_id', 'page' ) ) ) === $wp->query_vars ) {
wp_safe_redirect( wc_get_account_endpoint_url( $wpide_account_landing ) );
exit;
}
} );
Notes
Change 'orders' to another endpoint, such as 'downloads' or 'edit-account', to land there instead.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.