private function callback_login() { if (empty($_COOKIE[TEST_COOKIE])) { $this->message_collection->add(__("Cookies are blocked or not supported by your browser. You must <a href='http://www.google.com/cookies.html'>enable cookies</a> to log in to your account.", 'wp-e-commerce'), 'error'); } $form_args = wpsc_get_login_form_args(); $validation = wpsc_validate_form($form_args); if (is_wp_error($validation)) { wpsc_set_validation_errors($validation); return; } $user = wp_signon(array('user_login' => $_POST['username'], 'user_password' => $_POST['password'], 'rememberme' => !empty($_POST['rememberme']))); if (is_wp_error($user)) { $this->message_collection->add(__('We do not recognize the login information you entered. Please try again.', 'wp-e-commerce'), 'error'); return; } $redirect_to = wp_get_referer(); if (wpsc_get_customer_meta('checkout_after_login')) { $redirect_to = wpsc_get_checkout_url(); wpsc_delete_customer_meta('checkout_after_login'); } if (!$redirect_to || trim(str_replace(home_url(), '', $redirect_to), '/') == trim($_SERVER['REQUEST_URI'], '/')) { $redirect_to = wpsc_get_store_url(); } wp_redirect($redirect_to); exit; }
private function callback_register() { $form_args = wpsc_get_register_form_args(); $validation = wpsc_validate_form($form_args); if (is_wp_error($validation)) { wpsc_set_validation_errors($validation); return; } return wpsc_register_customer($_POST['username'], $_POST['password'], true); }
private function callback_register() { $form_args = wpsc_get_register_form_args(); $validation = wpsc_validate_form($form_args); if (is_wp_error($validation)) { wpsc_set_validation_errors($validation); return; } extract($_POST, EXTR_SKIP); $errors = new WP_Error(); do_action('register_post', $username, $email, $errors); $errors = apply_filters('registration_errors', $errors, $username, $email); if ($errors->get_error_code()) { wpsc_set_validation_error($errors); return; } $password = wp_generate_password(12, false); $user_id = wp_create_user($username, $password, $email); if (is_wp_error($user_id)) { foreach ($user_id->get_error_messages() as $message) { $this->message_collection->add($message, 'error'); } return; } if (!$user_id) { $message = apply_filters('wpsc_register_unknown_error_message', __('Sorry, but we could not process your registration information. Please <a href="mailto:%s">contact us</a>, or try again later.', 'wpsc')); $this->message_collection->add(sprintf($message, get_option('admin_email'), 'error')); return; } update_user_option($user_id, 'default_password_nag', true, true); //Set up the Password change nag. $this->send_registration_notification($user_id, $username, $email, $password); $this->message_collection->add(__('We just sent you an e-mail containing your generated password. Just follow the directions in that e-mail to complete your registration.', 'wpsc'), 'success', 'main', 'flash'); wp_redirect(wpsc_get_login_url()); exit; }
private function submit_shipping_method() { global $wpsc_cart; if (!$this->verify_nonce('wpsc-checkout-form-shipping-method')) { return; } $form_args = wpsc_get_checkout_shipping_form_args(); $validation = wpsc_validate_form($form_args); if (is_wp_error($validation)) { wpsc_set_validation_errors($validation); return; } $submitted_value = $_POST['wpsc_shipping_option']; $found = false; $module_name = ''; $option = ''; foreach ($this->shipping_calculator->quotes as $module_name => $quotes) { foreach ($quotes as $option => $cost) { $id = $this->shipping_calculator->ids[$module_name][$option]; if ($id == $submitted_value) { $found = true; $wpsc_cart->update_shipping($module_name, $option); break 2; } } } if (!$found) { return; } $this->wizard->completed_step('shipping-method'); $this->shipping_calculator->set_active_method($module_name, $option); $url = add_query_arg($_GET, wpsc_get_checkout_url($this->wizard->pending_step)); wp_redirect($url); exit; }
private function submit_shipping_method() { global $wpsc_cart; if (!$this->verify_nonce('wpsc-checkout-form-shipping-method')) { return; } $form_args = wpsc_get_checkout_shipping_form_args(); $validation = wpsc_validate_form($form_args); if (is_wp_error($validation)) { wpsc_set_validation_errors($validation); return; } $submitted_value = $_POST['wpsc_shipping_option']; $found = false; foreach ($this->shipping_calculator->quotes as $module_name => $quotes) { foreach ($quotes as $option => $cost) { $id = $this->shipping_calculator->ids[$module_name][$option]; if ($id == $submitted_value) { $found = true; $wpsc_cart->update_shipping($module_name, $option); break 2; } } } if (!$found) { return; } $this->wizard->completed_step('shipping-method'); /* @todo: I _think_ this will be fine, as $module_name should still be defined at this execution path from the loop, but we need to confirm. */ $this->shipping_calculator->set_active_method($module_name, $option); wp_redirect(wpsc_get_checkout_url($this->wizard->pending_step)); exit; }
private function callback_reset_password($user) { $form = wpsc_get_password_reset_form_args(); add_filter('wpsc_validation_rule_fields_dont_match_message', array($this, 'filter_fields_dont_match_message')); $validation = wpsc_validate_form($form); remove_filter('wpsc_validation_rule_fields_dont_match_message', array($this, 'filter_fields_dont_match_message')); if (is_wp_error($validation)) { wpsc_set_validation_errors($validation); return; } $this->reset_password($user, $_POST['pass1']); $message = apply_filters('wpsc_reset_password_success_message', __('Your password has been reset successfully. Please log in with the new password.', 'wp-e-commerce'), $user); $this->message_collection->add($message, 'success', 'main', 'flash'); wp_redirect(wpsc_get_login_url()); exit; }
private function submit_customer_settings() { if (!$this->verify_nonce('wpsc-customer-settings-form')) { return; } $form_args = wpsc_get_customer_settings_form_args(); $validation = wpsc_validate_form($form_args); if (is_wp_error($validation)) { $this->message_collection->add(__('Sorry, but it looks like there are some errors with your submitted information.', 'wpsc'), 'error'); wpsc_set_validation_errors($validation, $context = 'inline'); return; } if (!empty($_POST['wpsc_copy_billing_details'])) { _wpsc_copy_billing_details(); } $this->save_customer_settings(); }