Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

drupal 7: Get user information on account creation

I am trying to create a module where the users creates his account and on submit, i get his information and insert them in a second database too. I mean that he will exist in both databases and in Drupals user table and in user table of the other database.

How can i get his information and insert them to a custom database?

I am totally new to Drupal development.

Thank you in advance for any help or advice.

like image 447
JcDenton86 Avatar asked Oct 24 '12 09:10

JcDenton86


Video Answer


1 Answers

You will need to implement hook_form_alter() and use the following code:

function [YOUR_MODULE]_form_alter(&$form, &$form_state, $form_id)
{
    if($form_id == "user_register_form")
    {
        $form['#submit'][] = "your_custom_submit_callback";
    }
}

Then create the custom submit callback to manipulate the submitted values the way you like:

function your_custom_submit_callback($form, &$form_state)
{
    // your code goes here...
}

Hope this works... Muhammad.

like image 50
Muhammad Reda Avatar answered Sep 18 '22 15:09

Muhammad Reda