Update another table during registration, register event #472
-
Hello, My site only allows user to register when they are referred to the site and they enter a valid registration code, I have this working fine. However, I need to update my user referral table with the newly created user ID when the user is registering. I am using the "register" event triggered by Shield's RegisterController to call a custom class::method but as the user is not yet logged in, I am not sure how to get the current user ID. Is using the event the correct approach and if so, how can I get the current user ID without using auth()->id()? Thanks, |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
You can use the following explanations. |
Beta Was this translation helpful? Give feedback.
-
In addition to @datamweb's suggestion the piece you might be missing is that the new user is passed into the Register event as a parameter, so when you set up your listener it can receive the object: Events::on('register', static function ($user) {
echo $user->id;
}); |
Beta Was this translation helpful? Give feedback.
-
Can you share what you extend? I would like to implement something similar |
Beta Was this translation helpful? Give feedback.
In addition to @datamweb's suggestion the piece you might be missing is that the new user is passed into the Register event as a parameter, so when you set up your listener it can receive the object: