Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    This typically happens when your theme is overriding some of the core WooCommerce templates used by WooCommerce. Are you still experiencing the same issue after temporarily switching to the default Twenty Seventeen theme?

    Thread Starter 2basetech

    (@2basetech)

    Hi,
    While switching the theme its working fine.
    —————————–
    /**
    * Remove key and login from query string, set cookie, and redirect to account page to show the form.
    */
    public static function redirect_reset_password_link() {
    if ( is_account_page() && ! empty( $_GET[‘key’] ) && ! empty( $_GET[‘login’] ) ) {
    $value = sprintf( ‘%s:%s’, wp_unslash( $_GET[‘login’] ), wp_unslash( $_GET[‘key’] ) );
    WC_Shortcode_My_Account::set_reset_password_cookie( $value );

    wp_safe_redirect( add_query_arg( ‘show-reset-form’, ‘true’, ‘password-reset’ ) );
    exit;
    }
    }
    ————————————————————-

    /**
    * Handle reset password form.
    */
    public static function process_reset_password() {
    $posted_fields = array( ‘wc_reset_password’, ‘password_1’, ‘password_2’, ‘reset_key’, ‘reset_login’, ‘_wpnonce’ );

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

    if ( ! wp_verify_nonce( $posted_fields[‘_wpnonce’], ‘reset_password’ ) ) {
    return;
    }

    $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_redirect( add_query_arg( ‘password-reset’, ‘true’, wc_get_page_permalink( ‘myaccount’ ) ) );
    exit;
    }
    }
    }

    These two functions are found in my theme woocommerce/includes/class-wc-form-handler.php

    Is something wrong in this?

    Thanks in Advance

    Zach W

    (@dynamiczach)

    Automattic Happiness Engineer

    Howdy!

    The best thing to do is contact your theme developer for help with this.

    Otherwise, if the template is outdated you can try updating it by following the information here: https://docs.woocommerce.com/document/fix-outdated-templates-woocommerce/

    I’d highly recommend making sure you have a backup before updating, or ideally trying this on a test/staging site first.

    You can compare your themes /includes/class-wc-form-handler.php file with the default one here: https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-form-handler.php

    I hope this helps!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Password reset link is not working’ is closed to new replies.