After submit action in form_alter

16,018

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.

Share:
16,018
Cris
Author by

Cris

Updated on July 11, 2022

Comments

  • Cris
    Cris almost 2 years

    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()?