public function action() { if (isset($_POST['action']) && $_POST['action'] == 'change_password') { $errors = array(); $user = $this->wp->wpGetCurrentUser(); /** @noinspection PhpUndefinedFieldInspection */ if (!$this->wp->wpCheckPassword($_POST['password'], $user->user_pass, $user->ID)) { $errors[] = __('Current password is invalid.', 'jigoshop'); } if (empty($_POST['new-password'])) { $errors[] = __('Please enter new password.', 'jigoshop'); } else { if ($_POST['new-password'] != $_POST['new-password-2']) { $errors[] = __('Passwords do not match.', 'jigoshop'); } } if (!empty($errors)) { $this->messages->addError(join('<br/>', $errors), false); } else { $this->wp->wpUpdateUser(array('ID' => $user->ID, 'user_pass' => $_POST['new-password'])); $this->messages->addNotice(__('Password changed.', 'jigoshop')); $this->wp->redirectTo($this->options->getPageId(Pages::ACCOUNT)); } } }
/** * Returns currently logged in customer. * * @return Entity Current customer entity. */ public function getCurrent() { $user = $this->wp->wpGetCurrentUser(); return $this->factory->fetch($user); }