Reserve Your Free Seat for Our Next WooCommerce Class! Search
Business Bloomer
  • Join
  • WooCommerce Plugins
  • WooCommerce Tips
  • Log In
  • 0
  • Business Bloomer Club
  • WooCommerce Plugins
  • WooCommerce Tips
  • Log In
  • Search
  • Contact
  • Cart
WooCommerce Code Snippets My Account Redirect

WooCommerce: Redirect My Account Tab to URL

Last Revised: Mar 2021

STAY UPDATED

It’s nice to know the stuff I share here is used on my own website! In this case scenario, I have a custom “My Courses” tab under the My Account navigation menu; instead of showing the My Account tab content with a link, I want to save time and immediately redirect users to https://www.businessbloomer.com/woocommerce-online-courses/ instead.

So, how do you redirect My Account tabs to custom URLs? Well, thankfully it’s just a matter of a few lines of code. Enjoy!

To save an extra user click to Business Bloomer logged in users, I use the snippet below to automatically redirect them to the “Online Courses” page when they click on the My Account “My Courses” tab.

PHP Snippet: Redirect My Account Tab to Custom URL

Please note that each My Account tab, whether it’s a default one or a custom one, takes a “woocommerce_account_TABURL_endpoint” hook automatically, where “TABURL” is the URL of the My Account page e.g. “edit-address”.

By “hooking” into our tab, we can then set up a redirect as soon as the tab loads. In the snippet below you must change 2 things:

  1. the hook name “woocommerce_account_TABURL_endpoint” right after “add_action”, e.g. “woocommerce_account_edit-address_endpoint“. Please make sure you pay attention to underscores and hyphens.
  2. the redirect URL inside wp_safe_redirect
/**
 * @snippet       Redirect My Account Tab to Custom URL - WooCommerce
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 5.0
 * @community     https://businessbloomer.com/club/
 */
 
// Note 1: my account tab URL is "user-courses", see notes above the snippet if you wish to change the tab target

add_action( 'woocommerce_account_user-courses_endpoint', 'bbloomer_my_account_tab_redirect_url' ); 

// Note 2: I want to redirect above tab to /woocommerce-online-courses
 
function bbloomer_my_account_tab_redirect_url() { 
	wp_safe_redirect( '/woocommerce-online-courses' );
	exit;
}

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 setting up My Account tab redirects, you can also move the tab menu around, customize the color scheme, add banners, set up reCaptcha on the register and login forms, add, 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 🙂

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Custom Add to Cart URLs – The Ultimate Guide
    In WooCommerce you can add a product to the cart via a custom link. You just need to use the “add-to-cart” URL parameter followed by…
  • WooCommerce: Separate Login, Registration, My Account Pages
    There are times when you need to send logged out customers to a Login page and unregistered customers to a standalone Register page. As you…
  • WooCommerce: Add New Tab @ My Account Page
    One of the features of Business Bloomer Club is the provision of Premium WooCommerce Q&A Support to supporters who enroll. So, how to add an…
  • WooCommerce: How To Make A Website GDPR Compliant? (12 Steps)
    Ok, we all know that the EU General Data Protection Regulation (GDPR) will come into force on the 25th May 2018. So the main question…
  • WooCommerce Visual Hook Guide: My Account Pages
    Hey WooCustomizers, the Visual Hook Guide is back 🙂 In this episode, I’ve created a visual HTML hook guide for the WooCommerce Account Pages (there…

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

2 thoughts on “WooCommerce: Redirect My Account Tab to URL”

  1. carlos martinez
    June 30, 2021

    Hi Rodolfo, nice post!

    I have a little problem, I try to redirect people that go to the Dashboard but it doesnt work. I tried instead of

    woocommerce_account_user-courses_endpoint

    using

    woocommerce_account_dashboard_endpoint

    and

    woocommerce_account_endpoint

    and even

    woocommerce_account_/_endpoint

    but nothing seems to work. Do you know how to do it?

    Reply
    1. Rodolfo Melogli
      August 18, 2021

      “woocommerce_account_dashboard_endpoint” will not work, correct. “Dashboard” is not an endpoint. You can simply set up a 301 redirect from /my-account to whatever you like in such case

      Reply
Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Cancel reply

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


Search WooCommerce Tips

Popular Searches: Visual Hook Guides - Checkout Page - Cart Page - Single Product Page - Add to Cart - Emails - Shipping - Prices - Hosting

Recent Articles

  • WooCommerce: Send Email When a Coupon Is Used
  • WooCommerce: Simple Price Including/Excluding Tax Switcher
  • WooCommerce: Refund Request Button @ My Account
  • WooCommerce: Show or Hide Bank Accounts Based On Order
  • WooCommerce: Save Order Currency Exchange Rate

Latest Comments

  1. Rodolfo Melogli on WooCommerce: Add Checkout Fee for a Payment Gateway (e.g. PayPal)
  2. Rodolfo Melogli on WooCommerce Orders With No Customer and Zero Value
  3. Johnny on WooCommerce Orders With No Customer and Zero Value

Find Out More

  • Become a WooCommerce Expert
  • Business Bloomer Club
  • WooCommerce Blog
  • WooCommerce Weekly
  • Contact

Contact Info

Ciao! I'm Rodolfo Melogli, an Italian Civil Engineer who has turned into an international WooCommerce expert. You can contact me here:

Twitter: @rmelogli

Get in touch: Contact Page

Business Bloomer © 2011-2025 - VAT IT02722220817 - Terms of Use - Privacy Policy

Cart reminder?

x