in my magento 2.4.4 I have placed two observers, one for intercepting the registration process (customer_register_success
) and another one to intercept when the user logs in(customer_login
).
What I realized is that upon registration both events get fired, so basically my code is executed twice:
- the user lands on the registation page, completes the form, submits the data, the creation of the account is successful so the
customer_register_success
event is fired - then the user is redirected to their customer account and the
customer_login
event is fired.
My question is: in the customer_login
event, is there a way to know whether the account has just been created? Something like:
public function execute(MagentoFrameworkEventObserver $observer)
{
if($accountHasJustBeenCreated) return;
// proceed with original code
}