Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By unitazas on
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?
EDIT:
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?
Comments
If you want to add additional
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
snavas@acromedia.com
Software Developer
Acro Media
https://www.acromedia.com
1-800-818-4564
Skype: super.shaba
You want to also implement
You want to also implement hook_uninstall(), with db_drop_field() to drop the field on unintsall.
failure
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.