How to Create WooCommerce Lost Password Shortcode

WooCommerce Lost Password Shortcode

In this post, I want to show you how you can create WooCommerce lost password shortcode that you can use in several places in your WooCommerce development and customization.

In the previous post, I illustrate how to check if the WooCommerce plugin is active before you can proceed with more actions in your WooCommerce plugin development such as creating a lost password shortcode that is demonstrated in this post

WooCommerce Lost Password Shortcode

When you are creating a WooCommerce theme, you may want to have a custom reset password page as is the case in most custom WooCommerce themes of premium WooCommerce themes.

In this post, I want to demonstrate how to create a WordPress shortcode that will allow you to display the custom page for WooCommerce password recovery.

Create WooCommerce Lost Password Shortcode

The first step is to create the shortcode that will be used to create the custom WooCommerce recovery password page. You can create the WooCommerce lost password shortcode using the following code snippet.

/**
WooCommerce Lost Password Shortcode
**/

function njengah_lost_password_form( $atts ) {

return wc_get_template( 'myaccount/form-lost-password.php',
array( 'form' => 'lost_password' ) );

}
add_shortcode( 'njengah_lost_password_form', 'njengah_lost_password_form' );

This code can be placed in the functions.php of your WooCommerce theme or you can use this code in the plugin files then you can use the shortcode in the template page where you want to display the lost password form.

You can also publish a page to display the lost password recovery form as shown in the screenshot below:

WooCommerce lost password shortcode example

When you publish the page you should see the password recovery form as shown in the image below :

Create WooCommerce Lost Password Shortcode

Conclusion

In this post, we have looked at how to create a shortcode that displays the WooCommerce lost password form and this shortcode can be used in several places in your WooCommerce customization, WooCommerce plugin development, and custom WooCommerce theme development.

Similar Articles

  1. WooCommerce Redirect After Logout [Ultimate Guide]
  2. WooCommerce Redirect After Checkout: Redirect to Custom Thank You Page