if (!empty($_POST['register']) && wp_verify_nonce($nonce_value, 'woocommerce-register')) { $username = '******' === get_option('woocommerce_registration_generate_username') ? $_POST['username'] : ''; $password = '******' === 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'); } } } } WC_Form_Handler::init();
function woo_save_account_details() { if (isset($_POST)) { WC_Form_Handler::save_account_details(); } }