How to Add WooCommerce My Account Page Redirect

WooCommerce My Account Page Redirect

In WooCommerce My Account page you may want to change the page to a custom page and in this case, you can create a redirect to a custom page.

In the previous post, I shared how you can create woocommerce redirect after Checkout as well as how to create a WooCommerce redirect after logout.

Now in this post, I want to show you how to create WooCommerce My Account Page redirect.

WooCommerce My Account Page Redirect

First, there are several ways you can achieve the same results without adding any code snippet to redirect.

Change My Account End Point

The first would be to obviously change the My Account endpoint. In this case, if you needed to just change the URL of the My Account page you may not require a redirect function added to your WooCommerce store since this works out of the box.

Customize My Account Template

The second option you can use instead of creating a redirect for the My Account page, you can customize the myaccount/dashboard.php template. This is the best approach to customizing the WooCommerce My Account page since it gives you full control over the look and feel of the WooCommerce user account page.

Customize My Account Page Using a Plugin

Sometimes the best solution out there is a good plugin. Instead of trying to reinvent the wheel, you can opt to go for one of the best My Account customization plugins that will help you to quickly customize your My Account page instead of using a redirect code.

Redirect Using a Plugin

You can use one of these best redirect plugins to create the 301 permanent redirects of the my-account page to the page you prefer users to be redirected to once they are logged in or when they are not logged in.

Code Snippet to Redirect My Account Page

You can create a page with the data you want to display on the login page then you swap the default WooCommerce My Account page shortcode with a custom shortcode using the code snippet below:

//Hook 
add_shortcode('njengah_my_account','njengah_my_account_custom_shortcode');

//Callback 
function njengah_my_account_custom_shortcode(){
  
         $custompage=get_post(PAGE ID);//Replace the PAGE ID with the respective page ID for the page with the data
		 
          echo apply_filters('the_content',$custompage->post_content);

}

You can now use your custom My Account shortcode that you have created and change the content on the page whose ID you have applied to the code so that the changes can be reflected on My Account page.

Conclusion

In this post, I have shared with you how you can change the My Account page in WooCommerce. As you can see creating a redirect is not necessary since there are several ways you can change the My Account page without creating a redirect. If you need a redirect for the My Account page after logout, you may want to check out this article  – Ultimate WooCommerce Logout Redirect Guide

Similar Articles

  1. How to Hide Price When Out of Stock In WooCommerce