Question

I created a new tab on User edit, with a form

I want to save the data getting from the form the other table on Database (Ex: test_table) when I click on save user button, is there any method to do that?

Button of user back-office Magento 2

I try to use events

XML:

<event name="customer_account_edited">
    <observer name="test_event" instance="Testing\Test\Observer\TestUserOnSave"/>
</event>

PHP (TestUserOnSave)

public function execute(Observer $observer){
   $writer = new \Zend\Log\Writer\Stream(BP . '/var/log/logger.log');
   $logger = new \Zend\Log\Logger();
   $logger->addWriter($writer);
   $logger->info('test events');
}

But it's doesn't work, is there any solution?

Was it helpful?

Solution

You need to create module with observer that will load for example on

' admin_user_save_after` event

In observer you can insert Your function.

List of events: https://www.mageplaza.com/magento-2-module-development/magento-2-events.html

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top