Home » WooCommerce: Add New Tab @ My Account Page

WooCommerce: Add New Tab @ My Account Page

by adminkys

One of the features of Bloomer Armada is the provision of Premium WooCommerce Q&A Support to supporters who enroll. So, how to add an extra “tab” to the My Account page, and how to add content inside it?

Here’s the code I used (thanks to Mike Jolley for inspiration) – feel free to leave a comment below if you found this tutorial useful 🙂

WooCommerce: How to Add a New Tab to the My Account Page
WooCommerce: How to Add a New Tab to the My Account Page

PHP Snippet: How to Add a New Tab @ WooCommerce My Account Page

/**
 * @snippet       WooCommerce Add New Tab @ My Account
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 5.0
 * @donate $9     https://www.tutoraspire.com
 */
 
// ------------------
// 1. Register new endpoint (URL) for My Account page
// Note: Re-save Permalinks or it will give 404 error
 
function tutoraspire_add_premium_support_endpoint() {
    add_rewrite_endpoint( 'premium-support', EP_ROOT | EP_PAGES );
}
 
add_action( 'init', 'tutoraspire_add_premium_support_endpoint' );
 
// ------------------
// 2. Add new query var
 
function tutoraspire_premium_support_query_vars( $vars ) {
    $vars[] = 'premium-support';
    return $vars;
}
 
add_filter( 'query_vars', 'tutoraspire_premium_support_query_vars', 0 );
 
// ------------------
// 3. Insert the new endpoint into the My Account menu
 
function tutoraspire_add_premium_support_link_my_account( $items ) {
    $items['premium-support'] = 'Premium Support';
    return $items;
}
 
add_filter( 'woocommerce_account_menu_items', 'tutoraspire_add_premium_support_link_my_account' );
 
// ------------------
// 4. Add content to the new tab
 
function tutoraspire_premium_support_content() {
   echo '

Premium WooCommerce Support

Welcome to the WooCommerce support area. As a premium customer, you can submit a ticket should you have any WooCommerce issues with your website, snippets or customization. Please contact your theme/plugin developer for theme/plugin-related support.

'; echo do_shortcode( ' /* your shortcode here */ ' ); } add_action( 'woocommerce_account_premium-support_endpoint', 'tutoraspire_premium_support_content' ); // Note: add_action must follow 'woocommerce_account_{your-endpoint-slug}_endpoint' format

Is There a (Reliable) Plugin For That?

If you’d love to code but don’t feel 100% confident with PHP, I decided to look for a reliable plugin that achieves the same result.

In this case, I recommend the YITH WooCommerce Customize My Account Page plugin. On top of adding new My Account tabs, you can also move the tab menu around, customize the color scheme, add banners, set up reCaptcha on the register and login forms, sort, rename, delete and group tabs, conditionally show tabs to a given user role and much more.

But in case you hate plugins and wish to code (or wish to try that), then keep reading 🙂

You may also like