Heads up! This article contains PHP code and is intended for developers. If you want to add new custom tabs on the WooCommerce account page without any code, I recommend checking out the YITH WooCommerce Customize My Account Plugin.

WooCommerce by default adds the following items to the account page:

  • Dashboard
  • Orders
  • Downloads
  • Addresses
  • Account details
  • Logout


If you want to add a new item to the WooCommerce account page, you can use the following ready-to-use 4 code snippets in your theme’s (preferably child theme’s) functions.php file. Note that you’ll need to add all 4 code snippets below. Categorization is only for readability. Here are other ways of adding custom code snippets to your site.


1. Registering new item endpoint

* Change “new_item” and “new-item” to your preferred item name.

add_action( 'init', 'register_new_item_endpoint');

/**
 * Register New Endpoint.
 *
 * @return void.
 */
function register_new_item_endpoint() {
	add_rewrite_endpoint( 'new-item', EP_ROOT | EP_PAGES );
}


2. Query Vars

* Change “new_item” and “new-item” to your preferred item name.

add_filter( 'query_vars', 'new_item_query_vars' );

/**
 * Add new query var.
 *
 * @param array $vars vars.
 *
 * @return array An array of items.
 */
function new_item_query_vars( $vars ) {

	$vars[] = 'new-item';
	return $vars;
}


3. Add New Item

* Change “new_item”, “new-item”, “New Item” to your preferred item name.

add_filter( 'woocommerce_account_menu_items', 'add_new_item_tab' );

/**
 * Add New tab in my account page.
 *
 * @param array $items myaccount Items.
 *
 * @return array Items including New tab.
 */
function add_new_item_tab( $items ) {

	$items['new-item'] = 'New Item';
	return $items;
}


4. Add Contents To The New Item

* Change “new_item” and “New Item Contents here!” to your preferred item and its contents.

add_action( 'woocommerce_account_new-item_endpoint', 'add_new_item_content' );

/**
 * Add content to the new tab.
 *
 * @return  string.
 */
function add_new_item_content() {
	echo 'New Item Contents here!';
}


Once you’ve added these snippets, make sure to refresh the permalinks by going to Settings > Permalinks.


That’s it. I hope you found this helpful.

If you want to add a ‘Delete Account’ tab on the accounts page to allow users to delete their own accounts, you do not need to use any code snippets. There’s a built-in plugin WP Frontend Delete Account for you and more details on how to allow users to delete their own accounts.


WooCommerce account page
Output from the Twenty Twenty One theme





FAQ

How can I reorder WooCommerce account items?

/**
 * Reorder account items.
 * 
 * @return array Ordered Items.
 */
function reorder_account_menu( $items ) {
    return array(
	        'dashboard'          => __( 'Dashboard', 'woocommerce' ),
	        'orders'             => __( 'Orders', 'woocommerce' ),
	        'downloads'          => __( 'Downloads', 'woocommerce' ),
	        'edit-account'       => __( 'Edit Account', 'woocommerce' ),
	        'new-item'           => __( 'New Item', 'woocommerce' ),
	        'edit-address'       => __( 'Addresses', 'woocommerce' ),
	        'customer-logout'    => __( 'Logout', 'woocommerce' ),
    );

}
add_filter ( 'woocommerce_account_menu_items', 'reorder_account_menu' );

This puts “New Item” before the “Edit Addresses” and “Logout” Items.

How can I remove WooCommerce account items?

The same filter hook “woocommerce_account_menu_items” can be used to remove the WooCommerce account items. Following is the example of disabling the Edit Account tab.

/**
 * Remove Edit Account tab.
 * 
 * @return array Items.
 */
function remove_edit_account_tab( $items ) {

    unset( $items['edit-account'] );
    return $items.
}
add_filter ( 'woocommerce_account_menu_items', 'remove_edit_account_tab' );

If you want to remove other items, check their endpoints above.

How can I rename WooCommerce account items?

The same filter hook “woocommerce_account_menu_items” can be used to rename the WooCommerce account items. Following is the example of renaming the Dashboard tab.

/**
 * Rename Dashboard tab.
 * 
 * @return array Items.
 */
function rename_account_dashboard( $items ) {

    $items['dashboard'] = "Home";
    return $items.
}
add_filter ( 'woocommerce_account_menu_items', 'rename_account_dashboard' );

Did you know? You can find all the steps of your customers by using Customer Journey For WooCommerce plugin

CUSTOMER JOURNEY FOR WOOCOMMERCE

Happy developing. 😊

If you faced any issues or have any questions regarding the code snippets, let me know in the comments. I’ll be happy to help! Else, give this article a LIKE.

Add a new custom tab on the WooCommerce account page
Tagged on:

Sanjeev Aryal

Don't bury your thoughts, put your vision into reality ~ Bob Marley.

14 thoughts on “Add a new custom tab on the WooCommerce account page

  • September 2, 2022 at 5:10 pm
    Permalink

    This looks promising!

    How would I add a shortcode to the content so it can pull dynamic content?

    For example, I’m using Learndash and want to display the users enrolled courses. There is a specific shortcode for this – but not sure how to add the do_shortcode to this 🙂

    Reply
    • September 3, 2022 at 1:07 am
      Permalink

      Thanks for reaching out. In that case, you can just add do_shortocde in step 4. For Leardash course list of the user:


      function add_new_item_content() {
      echo do_shortcode( '[ld_course_list]' );
      }

      I hope this helps!

      Reply
      • September 3, 2022 at 3:01 pm
        Permalink

        Thanks so much, greatly appreciated!

        Reply
          • September 6, 2022 at 11:57 am
            Permalink

            Hi again,

            So no problems with adding the new tab. However, when you click on the tab it redirects to 404 page. I have tried a few times to re-save the permalinks but still no luck.

            Any suggestions what might be causing this?

            Cheers,
            Leanne

            Reply
            • September 6, 2022 at 1:27 pm
              Permalink

              Hi Leanne,

              First, you can try by manually entering the URL yoursite.com/my-account/new-item just like yoursite.com/my-account/edit-profile where ‘my-account’ is WooCommerce account page endpoint.

              If you could see the page with that, it’s still the permalinks issue. In this case, you might need to flush the permalinks by resetting the .htaccess file.

              If you still see 404 when manually adding that URL, revise the added code snippet.

              Thank you!

              Reply
              • September 7, 2022 at 3:41 pm
                Permalink

                Thanks!

                Actually on reviewing the code again I had an error 🙂

                So this is now working.

                This is not covered here and I have searched high and low but hoping you may know – is there any way to replace the text on the my account dashboard tab content using a code snippet?

                I know you can copy the template but I don’t have the ability to have a child theme with my hosting setup.

                Reply
                • September 7, 2022 at 4:00 pm
                  Permalink

                  Yes, it’s the same 4th snippet above that you can use. Replace ‘new-item’ with ‘dashboard’.

                  You don’t need snippet 1,2,3 because ‘dashboard’ endpoint is registered by default. So, to only change the content, use only snippet 4 and adjust the texts accordingly.

        • September 6, 2022 at 2:23 am
          Permalink

          Hi Joe, In that case, there might be something wrong with the shortcode or additional code you might be using. Can you share the full snippet you’re using through the contact form, I’d be happy to help: https://sanjeebaryal.com.np/contact.

          Reply
  • September 7, 2022 at 2:08 am
    Permalink

    I need this very functionality, except I need to redirect to a separate landing page upon tab click, as I cannot embed the content in the content section.

    Reply
    • September 7, 2022 at 2:47 am
      Permalink

      Hi Richard, instead of adding contents, you can redirect to any URL from snippet 4. Example:

      function add_new_item_content() {
      wp_redirect( 'https://example.com' );
      exit();
      }

      Use wp_safe_redirect(‘/landing-page’); if you’re redirecting on the same domain.

      I hope this helps!

      Reply
  • November 23, 2022 at 9:11 pm
    Permalink

    Hey Sanjeev!

    Get article, very helpful for setting up our custom account backend.

    One question, how can we add an icon for the new tab?

    Thank you in advanced,

    Reply
    • November 24, 2022 at 1:49 am
      Permalink

      Great question. Adding new icon to the account tab is just using CSS. Example below:

      .woocommerce-MyAccount-navigation ul li.woocommerce-MyAccount-navigation-link–new-item a:before {
      content: “\f4fe”;
      }

      Note the “new-item” term.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Pin It on Pinterest