i need to insert data in my tables after user creation. I think to use hook_form_alter()
for $form_id == "user_register"
but I don't know how to say "after you created user, do this."
How can I do it in hook_form_alter()
?
You can add custom submit handler to forms like this.
function hook_form_user_register_alter(&$form, &$form_state) {
// ...
$form['#submit'][] = 'yourModule_user_register_submit';
}
function yourModule_user_register_submit($form, &$form_state) {
// do what you want to do after registration
}
I'd also recommend to use Drupal's Triggers & Actions to achieve this. AFAIK there was a bug with one of the triggers that fire after user registration. Don't know if that has been fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With