I'm trying to add an action after user signup so that we can post the clients external system so we can retrieve a customer number that we require. My question is does EVENT_BEFORE_VERIFY_EMAIL run as soon as the user signs up or is their another method of achieving this.
1 Answer
You could use the EVENT_AFTER_SAVE
event to handle this, if you don't need the external call to be made before the user has verified their email.
Something like this:
Event::on(
User::class,
User::EVENT_AFTER_SAVE,
function(ModelEvent $event) {
/** @var User $user */
$user = $event->sender;
// If this is a new user
if ($event->isNew) {
// Call external system here
}
}
);
-
Thank you that's exactly what I was looking for since account verification won't be needed for the store but we still need to create a new customer on their internal system.– spenceCommented Dec 1, 2020 at 17:49