Beispiel #1
0
 /**
  * Handle Shopp login processing
  *
  * @author Jonathan Davis
  * @since 1.0
  *
  * @return void
  **/
 public function process()
 {
     if (ShoppRegistration::submitted()) {
         new ShoppRegistration();
         add_action('shopp_customer_registered', array($this, 'login'));
     }
     if (isset($_REQUEST['acct']) && 'logout' == $_REQUEST['acct'] || isset($_REQUEST['logout'])) {
         // Set the last logged out action to save the session and redirect to remove the logout request
         add_action('shopp_logged_out', array($this, 'redirect'), 100);
         // Trigger the logout
         do_action('shopp_logout');
     }
     if ('wordpress' == shopp_setting('account_system')) {
         // See if the wordpress user is already logged in
         $user = wp_get_current_user();
         // Wordpress user logged in, but Shopp customer isn't
         if (!empty($user->ID) && !$this->Customer->loggedin()) {
             if ($Account = new ShoppCustomer($user->ID, 'wpuser')) {
                 $this->login($Account);
                 $this->Customer->wpuser = $user->ID;
                 return;
             }
         }
     }
     if (!self::submitted()) {
         return false;
     }
     // Prevent checkout form from processing
     remove_all_actions('shopp_process_checkout');
     if (!isset($_POST['account-login']) || empty($_POST['account-login'])) {
         return shopp_add_error(__('You must provide a valid login name or email address to proceed.', 'Shopp'), SHOPP_AUTH_ERR);
     }
     // Add a login redirect as the very last action if a redirect parameter is provided in the request; Props @alansherwood
     if (isset($_REQUEST['redirect'])) {
         add_action('shopp_authed', array($this, 'redirect'), 100);
     }
     $mode = 'loginname';
     if (false !== strpos($_POST['account-login'], '@')) {
         $mode = 'email';
     }
     $this->auth($_POST['account-login'], $_POST['password-login'], $mode);
 }
Beispiel #2
0
 /**
  * Creates a customer record (and WordPress user) and attaches the order to it
  *
  * @author Jonathan Davis
  * @since 1.2
  *
  * @return void
  **/
 public function accounts($Event)
 {
     $Purchase = $Event->order();
     if (!$Purchase) {
         shopp_debug('No purchase available for account registration processing.');
         return;
     }
     if (!$this->Customer->exists()) {
         $registration = $Purchase->registration();
         if (empty($registration)) {
             shopp_debug('No purchase registration data available for account registration processing.');
             return;
         }
         $this->Customer->copydata($registration['Customer']);
         $this->Billing->copydata($registration['Billing']);
         $this->Shipping->copydata($registration['Shipping']);
         // Validation already conducted during the checkout process
         add_filter('shopp_validate_registration', '__return_true');
         // Prevent redirection to account page after registration
         add_filter('shopp_registration_redirect', '__return_false');
     }
     ShoppRegistration::process();
     // Update Purchase with link to created customer record
     if (!empty($this->Customer->id)) {
         $Purchase = ShoppPurchase();
         if ($Purchase->id != $Event->order) {
             $Purchase = new ShoppPurchase($Event->order);
         }
         $Purchase->customer = $this->Customer->id;
         $Purchase->billing = $this->Billing->id;
         $Purchase->shipping = $this->Shipping->id;
         $Purchase->save();
     }
 }
Beispiel #3
0
 /**
  * Account registration processing.
  *
  * @since 1.3
  **/
 public function registration()
 {
     // Validation already conducted during the checkout process
     add_filter('shopp_validate_registration', '__return_true');
     // Prevent redirection to account page after registration
     add_filter('shopp_registration_redirect', '__return_false');
     ShoppRegistration::process();
 }