Skip to main content
added 756 characters in body
Source Link

It can be easily done by the following module.

https://github.com/amitshree/magento2-account-approval/blob/master/Plugin/Customer/Controller/Account/LoginPost.php

Done by 2 methods

1.Event customer_register_success

 public function execute(\Magento\Framework\Event\Observer $observer) { $this->coreRegistry->register('is_new_account', true); } 

2.Override Magento\Customer\Model\Account\Redirect

 $this->messageManager->getMessages(true); // Adding a custom message $this->messageManager->addErrorMessage(__('Your account is not approved. Kindly contact website admin for assitance.')); // Destroy the customer session in order to redirect him to the login page $this->session->destroy(); /** @var \Magento\Framework\Controller\Result\Redirect $result */ $result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $result->setUrl($this->url->getUrl('customer/account/login')); return $result 

It can be easily done by the following module.

https://github.com/amitshree/magento2-account-approval/blob/master/Plugin/Customer/Controller/Account/LoginPost.php

Done by 2 methods

1.Event customer_register_success

2.Override Magento\Customer\Model\Account\Redirect

It can be easily done by the following module.

https://github.com/amitshree/magento2-account-approval/blob/master/Plugin/Customer/Controller/Account/LoginPost.php

Done by 2 methods

1.Event customer_register_success

 public function execute(\Magento\Framework\Event\Observer $observer) { $this->coreRegistry->register('is_new_account', true); } 

2.Override Magento\Customer\Model\Account\Redirect

 $this->messageManager->getMessages(true); // Adding a custom message $this->messageManager->addErrorMessage(__('Your account is not approved. Kindly contact website admin for assitance.')); // Destroy the customer session in order to redirect him to the login page $this->session->destroy(); /** @var \Magento\Framework\Controller\Result\Redirect $result */ $result = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT); $result->setUrl($this->url->getUrl('customer/account/login')); return $result 
Source Link

It can be easily done by the following module.

https://github.com/amitshree/magento2-account-approval/blob/master/Plugin/Customer/Controller/Account/LoginPost.php

Done by 2 methods

1.Event customer_register_success

2.Override Magento\Customer\Model\Account\Redirect