WordPress at Your Fingertips
function is not described

WC_Form_Handler::process_reset_password() public WC 1.0

Handle reset password form.

{} It's a method of the class: WC_Form_Handler{}

Return

null. Nothing.

Usage

$result = WC_Form_Handler::process_reset_password();

Code of WC_Form_Handler::process_reset_password() WC 5.8.0

public static function process_reset_password() {
	$nonce_value = wc_get_var( $_REQUEST['woocommerce-reset-password-nonce'], wc_get_var( $_REQUEST['_wpnonce'], '' ) ); // @codingStandardsIgnoreLine.

	if ( ! wp_verify_nonce( $nonce_value, 'reset_password' ) ) {
		return;
	}

	$posted_fields = array( 'wc_reset_password', 'password_1', 'password_2', 'reset_key', 'reset_login' );

	foreach ( $posted_fields as $field ) {
		if ( ! isset( $_POST[ $field ] ) ) {
			return;
		}

		if ( in_array( $field, array( 'password_1', 'password_2' ), true ) ) {
			// Don't unslash password fields
			// @see https://github.com/woocommerce/woocommerce/issues/23922.
			$posted_fields[ $field ] = $_POST[ $field ]; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
		} else {
			$posted_fields[ $field ] = wp_unslash( $_POST[ $field ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
		}
	}

	$user = WC_Shortcode_My_Account::check_password_reset_key( $posted_fields['reset_key'], $posted_fields['reset_login'] );

	if ( $user instanceof WP_User ) {
		if ( empty( $posted_fields['password_1'] ) ) {
			wc_add_notice( __( 'Please enter your password.', 'woocommerce' ), 'error' );
		}

		if ( $posted_fields['password_1'] !== $posted_fields['password_2'] ) {
			wc_add_notice( __( 'Passwords do not match.', 'woocommerce' ), 'error' );
		}

		$errors = new WP_Error();

		do_action( 'validate_password_reset', $errors, $user );

		wc_add_wp_error_notices( $errors );

		if ( 0 === wc_notice_count( 'error' ) ) {
			WC_Shortcode_My_Account::reset_password( $user, $posted_fields['password_1'] );

			do_action( 'woocommerce_customer_reset_password', $user );

			wp_safe_redirect( add_query_arg( 'password-reset', 'true', wc_get_page_permalink( 'myaccount' ) ) );
			exit;
		}
	}
}