I am trying to create additional fields in my user registration form using default Drupal field system, but it creates another table in database for itself. What I want to do is to find way to add additional columns into users table.
Is there any way I can change each fields settings?

What I have done so far...
Edited user_account_form() and added this code:

$form['account']['invite_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Invitation key'),
    '#maxlength' => INVITATION_MAX_LENGTH,
    '#description' => t('Random text'),
    '#required' => TRUE,
    '#attributes' => array('class' => array('invite_key')),
    '#default_value' => (!$register ? $account->invitation : ''), 

Now the Invitation key field appears on registration form, but after the registration process no information appears at users table on database.
What I'm missing?


shabana.navas’s picture

If you want to add additional fields to the users table, you need to create a custom module and make a call to hook_schema_alter and also do db_add_field in hook_install of your module. Hope things are a bit clearer now.

Shabana Navas
Software Developer
Acro Media
Skype: super.shaba

Jaypan’s picture

You want to also implement hook_uninstall(), with db_drop_field() to drop the field on unintsall.

unitazas’s picture

I was trying to do that for a week, but no luck.
Can anyone post a example code how to do it, because I still don't get the base structure of drupal and how it works.