Fix for Fix for Example of hook_user()

  1. <?php
  2. // Put that as user_example.module
  3. // Tested on D5
  4.  
  5. /**
  6.  * Implementation of hook_user().
  7.  */
  8. function user_example_user($op, &$form_values, &$account, $category = NULL) {
  9.   switch ($op) {
  10.     case 'form':
  11.       // The user edit form can be modified here.
  12.       $form = array();
  13.       $form['custom_field'] = array(
  14.         '#title' => t('My Custom Feild'),
  15.         '#type' => 'textfield',
  16.         '#description' => t('Type anything and it will be saved!'),
  17.         '#default_value' => $account->custom_field,
  18.       );
  19.       return $form;
  20.       break;
  21.  
  22.     case 'submit':
  23.       // Additional fields can be added here.
  24.       // all extra fields are going to be serialized into 'data' field
  25.       // in the database.
  26.  
  27.       // Our form field above is called 'custom_field'
  28.       // Now it's part of the $form_values array already, so it's going to be saved
  29.       // automatically we don't need to do anything!
  30.       // But say we want to add some processing, like capitalize the field?
  31.       // Then uncomment this line:
  32.  
  33.       // $form_values['custom_field'] = strtoupper($form_values['custom_field']);
  34.       break;
  35.   }
  36. }

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.