Addicte Posted April 26 Share Posted April 26 (edited) Bonjour, je voudrais faire un override pour que lorsqu'un client s'inscrit le compte soit en désactivé par défaut. Voici ce que j'ai fait, mais ça ne marche pas, j'ai juste rajouté la ligne : $customer->active = false; <?php use PrestaShop\PrestaShop\Core\Crypto\Hashing as Crypto; use Symfony\Component\Translation\TranslatorInterface; class CustomerPersister extends CustomerPersisterCore { private $errors = []; private $context; private $crypto; private $translator; private $guest_allowed; public function __construct( Context $context, Crypto $crypto, TranslatorInterface $translator, $guest_allowed ) { parent::__construct($context, $crypto, $translator, $guest_allowed); $this->context = $context; $this->crypto = $crypto; $this->translator = $translator; $this->guest_allowed = $guest_allowed; } public function getErrors() { return parent::getErrors(); } public function save(Customer $customer, $clearTextPassword, $newPassword = '', $passwordRequired = true) { return parent::save($customer, $clearTextPassword, $newPassword, $passwordRequired); } private function update(Customer $customer, $clearTextPassword, $newPassword, $passwordRequired = true) { return parent::update($customer, $clearTextPassword, $newPassword, $passwordRequired); } private function create(Customer $customer, $clearTextPassword) { if (!$clearTextPassword) { if (!$this->guest_allowed) { $this->errors['password'][] = $this->translator->trans( 'Password is required', [], 'Shop.Notifications.Error' ); return false; } $clearTextPassword = $this->crypto->hash( microtime(), _COOKIE_KEY_ ); $customer->is_guest = true; } $customer->passwd = $this->crypto->hash( $clearTextPassword, _COOKIE_KEY_ ); if (Customer::customerExists($customer->email, false, true)) { $this->errors['email'][] = $this->translator->trans( 'An account was already registered with this email address', [], 'Shop.Notifications.Error' ); return false; } // Modification : Définir active avant l'appel à la méthode save de l'objet Customer $customer->active = false; $ok = $customer->save(); if ($ok) { $this->context->updateCustomer($customer); $this->context->cart->update(); $this->sendConfirmationMail($customer); Hook::exec('actionCustomerAccountAdd', [ 'newCustomer' => $customer, ]); } return $ok; } private function sendConfirmationMail(Customer $customer) { return parent::sendConfirmationMail($customer); } } je voudrais également revenir sur la page d'inscription, ou une autre pour informer qu'il faut attendre la validation du compte. Merci d'avance Edited April 29 by Addicte Resolved (see edit history) Link to comment Share on other sites More sharing options...
Mediacom87 Posted April 29 Share Posted April 29 Bonjour, Pour réaliser ce que vous souhaitez, le mieux est de développer un module, ce que j'ai fait pour un client. Link to comment Share on other sites More sharing options...
Addicte Posted April 29 Author Share Posted April 29 Bonjour, c'est ce que j'ai fait au final sur votre site directement Merci 1 Link to comment Share on other sites More sharing options...
Mediacom87 Posted April 29 Share Posted April 29 Il y a 2 heures, Addicte a dit : Bonjour, c'est ce que j'ai fait au final sur votre site directement Merci Merci de la confiance que vous m'accordez. À la moindre question, n'hésitez pas à revenir vers moi. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now