WC_Shortcode_My_Account::lost_password()public staticWC 1.0

Lost password page handling.

Method of the class: WC_Shortcode_My_Account{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = WC_Shortcode_My_Account::lost_password();

WC_Shortcode_My_Account::lost_password() code WC 8.7.0

public static function lost_password() {
	/**
	 * After sending the reset link, don't show the form again.
	 */
	if ( ! empty( $_GET['reset-link-sent'] ) ) { // WPCS: input var ok, CSRF ok.
		return wc_get_template( 'myaccount/lost-password-confirmation.php' );

		/**
		 * Process reset key / login from email confirmation link
		 */
	} elseif ( ! empty( $_GET['show-reset-form'] ) ) { // WPCS: input var ok, CSRF ok.
		if ( isset( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ) && 0 < strpos( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ], ':' ) ) {  // @codingStandardsIgnoreLine
			list( $rp_id, $rp_key ) = array_map( 'wc_clean', explode( ':', wp_unslash( $_COOKIE[ 'wp-resetpass-' . COOKIEHASH ] ), 2 ) ); // @codingStandardsIgnoreLine
			$userdata               = get_userdata( absint( $rp_id ) );
			$rp_login               = $userdata ? $userdata->user_login : '';
			$user                   = self::check_password_reset_key( $rp_key, $rp_login );

			// Reset key / login is correct, display reset password form with hidden key / login values.
			if ( is_object( $user ) ) {
				return wc_get_template(
					'myaccount/form-reset-password.php',
					array(
						'key'   => $rp_key,
						'login' => $rp_login,
					)
				);
			}
		}
	}

	// Show lost password form by default.
	wc_get_template(
		'myaccount/form-lost-password.php',
		array(
			'form' => 'lost_password',
		)
	);
}