Show div after process register, woo-commerce

Viewed 328

After registration process in website, I want to show a hidden div the div are in the same page. but after registration, the page will load and show the same page.

here's the form-handler.php

public static function process_registration() {
    $nonce_value = isset( $_POST['_wpnonce'] ) ? $_POST['_wpnonce'] : '';
    $nonce_value = isset( $_POST['woocommerce-register-nonce'] ) ? $_POST['woocommerce-register-nonce'] : $nonce_value;

    if ( ! empty( $_POST['register'] ) && wp_verify_nonce( $nonce_value, 'woocommerce-register' ) ) {
        $username = 'no' === get_option( 'woocommerce_registration_generate_username' ) ? $_POST['username'] : '';
        $password = 'no' === get_option( 'woocommerce_registration_generate_password' ) ? $_POST['password'] : '';
        $email    = $_POST['email'];

        try {
            $validation_error = new WP_Error();
            $validation_error = apply_filters( 'woocommerce_process_registration_errors', $validation_error, $username, $password, $email );

            if ( $validation_error->get_error_code() ) {
                throw new Exception( $validation_error->get_error_message() );
            }

            // Anti-spam trap
            if ( ! empty( $_POST['email_2'] ) ) {
                throw new Exception( __( 'Anti-spam field was filled in.', 'woocommerce' ) );
            }

            $new_customer = wc_create_new_customer( sanitize_email( $email ), wc_clean( $username ), $password );

            if ( is_wp_error( $new_customer ) ) {
                throw new Exception( $new_customer->get_error_message() );
            }

            if ( apply_filters( 'woocommerce_registration_auth_new_customer', true, $new_customer ) ) {
                wc_set_customer_auth_cookie( $new_customer );
            }

            wp_safe_redirect( apply_filters( 'woocommerce_registration_redirect', wp_get_referer() ? wp_get_referer() : wc_get_page_permalink( 'myaccount' ) ) );
            exit;

        } catch ( Exception $e ) {
            wc_add_notice( '<strong>' . __( 'Error', 'woocommerce' ) . ':</strong> ' . $e->getMessage(), 'error' );
        }
    }
}

and the div

<div class="alert success">
    <span class="closebtn">&times;</span>
    <strong>Registration Success!</strong> Check Email.
</div>

and this's the js code

   jQuery('input.btn.btn-default.size-new-account').click(function() {
  jQuery('.alert.success').show();
});

but the problem, how can I understand the flow of registration and I can use condition or another way. so the notify will show if the validation is success and also show after load page.

1 Answers
Related