Customer registration event for rest API customer_register_success
event not working.
I have used customer_save_after
event and it is working fine in customer register rest API call.
Follow below file path to create custom module and call event in customer registration rest API call
Filepath: magento/app/code/Vendor/CustomerRegister/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Vendor_CustomerRegister',
__DIR__
);
Filepath: magento/app/code/Vendor/CustomerRegister/etc/module.xml
<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_CustomerRegister" setup_version="1.0.0" />
</config>
Filepath:
magento/app/code/Vendor/CustomerRegister/etc/webapi_rest/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="customer_save_after">
<observer name="customer_resgister_observerAPI" instance="Vendor\CustomerRegister\Observer\CreatePostCustomer" />
</event>
</config>
Filepath:
magento/app/code/Vendor/CustomerRegister/Observer/CreatePostCustomer.php
<?php
namespace Vendor\CustomerRegister\Observer;
use Magento\Framework\Event\ObserverInterface;
use \Magento\Framework\Event\Observer as Observer;
class CreatePostCustomer implements ObserverInterface
{
public function execute(Observer $observer)
{
$data = $observer->getEvent()->getCustomer();
// Add custom logic here
}
}
Hope it help!