author = $authorFactory; $this->_helper = $helper; $this->messageManager = $manager; } /** * @param Observer $observer */ public function execute(Observer $observer) { $accountController = $observer->getData('account_controller'); $customer = $observer->getData('customer'); /** @var CreatePost $accountController */ if ($this->_helper->isEnabled() && $accountController->getRequest()->getParam('is_mp_author')) { $data = [ 'customer_id' => $customer->getId(), 'name' => $customer->getFirstname(), 'type' => '1', 'status' => $this->_helper->getConfigGeneral('auto_approve') ? 1 : 0 ]; $author = $this->author->create(); $author->addData($data); try { $author->save(); } catch (Exception $e) { $this->messageManager->addExceptionMessage($e, __('Something went wrong while saving the Author.')); } } } }