mktm20111 Posted March 30, 2021 Share Posted March 30, 2021 Hello, I have created a store for professionals where I must manually verify & activate the customer account. The problem is: when a customer creates his account, nothing warns him that his account must be validated. I created a CMS page explaining this but I cannot get it to redirect to the CMs page after creating the account. I have already searched the forum quite a bit but no solution works. If possible to explain where to put the code ect ... it would be good, because too many people say "you must put this code" without explaining anything. I am on the prestashop version 1.7.7.1 thank you in advance Link to comment Share on other sites More sharing options...
mktm20111 Posted March 31, 2021 Author Share Posted March 31, 2021 Anyone? thisd is the code in AuthController.php <?php /** * Copyright since 2007 PrestaShop SA and Contributors * PrestaShop is an International Registered Trademark & Property of PrestaShop SA * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.md. * It is also available through the world-wide-web at this URL: * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to https://devdocs.prestashop.com/ for more information. * * @author PrestaShop SA and Contributors <[email protected]> * @copyright Since 2007 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) */ class AuthControllerCore extends FrontController { public $ssl = true; public $php_self = 'authentication'; public $auth = false; public function checkAccess() { if ($this->context->customer->isLogged() && !$this->ajax) { $this->redirect_after = ($this->authRedirection) ? urlencode($this->authRedirection) : 'my-account'; $this->redirect(); } return parent::checkAccess(); } public function initContent() { $should_redirect = false; if (Tools::isSubmit('submitCreate') || Tools::isSubmit('create_account')) { $register_form = $this ->makeCustomerForm() ->setGuestAllowed(false) ->fillWith(Tools::getAllValues()); if (Tools::isSubmit('submitCreate')) { $hookResult = array_reduce( Hook::exec('actionSubmitAccountBefore', [], null, true), function ($carry, $item) { return $carry && $item; }, true ); if ($hookResult && $register_form->submit()) { $should_redirect = true; } } $this->context->smarty->assign([ 'register_form' => $register_form->getProxy(), 'hook_create_account_top' => Hook::exec('displayCustomerAccountFormTop'), ]); $this->setTemplate('customer/registration'); } else { $login_form = $this->makeLoginForm()->fillWith( Tools::getAllValues() ); if (Tools::isSubmit('submitLogin')) { if ($login_form->submit()) { $should_redirect = true; } } $this->context->smarty->assign([ 'login_form' => $login_form->getProxy(), ]); $this->setTemplate('customer/authentication'); } parent::initContent(); if ($should_redirect && !$this->ajax) { $back = urldecode(Tools::getValue('back')); if (Tools::urlBelongsToShop($back)) { // Checks to see if "back" is a fully qualified // URL that is on OUR domain, with the right protocol return $this->redirectWithNotifications($back); } // Well we're not redirecting to a URL, // so... if ($this->authRedirection) { // We may need to go there if defined return $this->redirectWithNotifications($this->authRedirection); } // go home return $this->redirectWithNotifications(__PS_BASE_URI__); } } public function getBreadcrumbLinks() { $breadcrumb = parent::getBreadcrumbLinks(); if (Tools::isSubmit('submitCreate') || Tools::isSubmit('create_account')) { $breadcrumb['links'][] = [ 'title' => $this->trans('Create an account', [], 'Shop.Theme.Customeraccount'), 'url' => $this->context->link->getPageLink('authentication'), ]; } else { $breadcrumb['links'][] = [ 'title' => $this->trans('Log in to your account', [], 'Shop.Theme.Customeraccount'), 'url' => $this->context->link->getPageLink('authentication'), ]; } return $breadcrumb; } } Link to comment Share on other sites More sharing options...
Guest Posted April 1, 2021 Share Posted April 1, 2021 Am I right that an unregistered person can't shop at the store? Link to comment Share on other sites More sharing options...
Guest Posted April 1, 2021 Share Posted April 1, 2021 (edited) $registrationRedirectUrl = $this->context->link->getCMSLink('3', 'my-custom-cms-page-id-3'); Tools::redirect($registrationRedirectUrl); You have to either 1. edit the ./classes/form/CustomerPersister.php file * add redirect after $this-> sendConfirmationMail ($customer); 2. Create a module and use hookActionCustomerAccountAdd Edited April 1, 2021 by Guest (see edit history) Link to comment Share on other sites More sharing options...
mktm20111 Posted April 1, 2021 Author Share Posted April 1, 2021 12 hours ago, Guest said: Am I right that an unregistered person can't shop at the store? correct, customer can see the products but can not see prices and can not buy until registered Link to comment Share on other sites More sharing options...
mktm20111 Posted April 1, 2021 Author Share Posted April 1, 2021 12 hours ago, Guest said: $registrationRedirectUrl = $this->context->link->getCMSLink('3', 'my-custom-cms-page-id-3'); Tools::redirect($registrationRedirectUrl); You have to either 1. edit the ./classes/form/CustomerPersister.php file * add redirect after $this-> sendConfirmationMail ($customer); 2. Create a module and use hookActionCustomerAccountAdd 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; } $ok = $customer->save(); if ($ok) { $this->context->updateCustomer($customer); $this->context->cart->update(); $this->sendConfirmationMail($customer); $registrationRedirectUrl = $this->context->link->getCMSLink('4', '4-verification-de-compte'); Tools::redirect($registrationRedirectUrl); Hook::exec('actionCustomerAccountAdd', [ 'newCustomer' => $customer, ]); } return $ok; } private function sendConfirmationMail(Customer $customer) { if ($customer->is_guest || !Configuration::get('PS_CUSTOMER_CREATION_EMAIL')) { return true; } return Mail::Send( $this->context->language->id, 'account', $this->translator->trans( 'Welcome!', [], 'Emails.Subject' ), [ '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{email}' => $customer->email, ], $customer->email, $customer->firstname . ' ' . $customer->lastname ); } } Link to comment Share on other sites More sharing options...
mktm20111 Posted April 1, 2021 Author Share Posted April 1, 2021 @Guest i added your code as you can see but without success, i'm wondering why after the email confirmation? because there will not be an email until i validate manually the account Link to comment Share on other sites More sharing options...
Guest Posted April 1, 2021 Share Posted April 1, 2021 Because in the administration you can set up automatic sending of an email to the customer that his account will be verified. 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