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
Joe is an experienced full-stack web developer with a decade of industry experience in the LAMP & MERN stacks, WordPress, WooCommerce, and JavaScript – (diverse portfolio). He has a passion for creating elegant and user-friendly solutions and thrives in collaborative environments. In his spare time, he enjoys exploring new tech trends, tinkering with new tools, and contributing to open-source projects. You can hire me here for your next project.
Similar Articles
- Complete Guide to Using WordPress Custom Hooks do_action & apply_filters With Examples
- 40+ Best WordPress Contact Form Plugins for Easy Contact
- How to Change Checkout Button Text in WooCommerce [Place Order]
- How to Create WordPress Database in PHPMyAdmin
- How to Create Custom Widget Area in WordPress Step by Step
- How to Hide Update Cart Button WooCommerce Cart Page
- How to Create WooCommerce Storefront Child Theme [Complete Guide]
- How to Count Items Added to Cart WooCommerce Cart Count Code
- 5+ Useful Ways to Limit WordPress Excerpt Length Like a Pro
- WooCommerce Login Redirect Hook Explained with Example
- How to Get Current Product Category Name in WooCommerce
- WooCommerce Redirect Users After Registration by Roles
- How to Get Order Details After Checkout In WooCommerce
- How to Get Order ID on Checkout Page WooCommerce
- How to Create Custom Query Pagination In WordPress With an Example
- How to Remove or Disable auto In WordPress Posts & Custom Post Types
- How to Hide Price When Out of Stock In WooCommerce