cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2 Use Observer When Customer Account is Created

Magento 2 Use Observer When Customer Account is Created

When a users comes to our website, and wants to create a new account, I am wanting to capture the customers data before the customer has been successfully registered. 

 

So after a user enters their name, email and password and clicks create account, I am wanting to setup an observer that will gather the form data. Then make an api call that will send me back a JSON POST response, I then want to take a value from the response and use it to save one of the customer's attributes.

 

I have tried 

 

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<events>
<event name="customer_validate">
<observer name="setNumber" instance="V\ModuleName\Observer\Customer" />
</event>
</events>
</config>



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<events>
<event name="customer_register_success">
<observer name="setNumber" instance="V\Module\Observer\Customer" />
</event>
</events>
</config>


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<events>
<event name="customer_save_after">
<observer name="setNumber" instance="V\ModuleName\Observer\Customer" />
</event>
</events>
</config>

 

So I am wondering what Observer should I use to be able to do this, I have managed to be successful in setting up my observer for the checkout_cart_product_add_after but I am unsuccessful in my attempt to get the customer.

 

Any help would be greatly appreciated