After submitting the action to form_alter

I need to insert data into my tables after creating the user. I am thinking of using hook_form_alter() for $form_id == "user_register" , but I don't know how to say "after creating the user, do it."

How can I do this in hook_form_alter() ?

+4
source share
1 answer

You can add a 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 would also recommend using Drupal Triggers and Actions to achieve this. AFAIK an error occurred with one of the triggers that fire after user registration. I don't know if this is fixed.

+17
source

Source: https://habr.com/ru/post/1336759/


All Articles