Search code examples
drupal-7

Change and add fields to registration form drupal 7


hi i am trying to add a new field of email to my module drupal 7, but I get nothing, can someone help me find the error, (sorry for bad english :()

    function module_form_alter($form_id,&$form){
        if($form_id == 'user_register_form'){ 
            print_r($form_id);
            $form['email'] = array(
                    '#type' => 'textfield',
                  '#title' => t('Ingresar su Email'),
                  '#default_value' => 'Email',
                  '#size' => 60,
                  '#maxlength' => 128,
                  '#required' => TRUE,
             );
        }
    }

?>

Solution

  • function name "module_form_alter" should be the name of your module plus "_form_alter", not the word "module". So create a module folder, say "mycustomlogin", then in the mycustomlogin.module file within that folder, you'd have this function, but rename to use the module name "mycustomlogin_form_alter" for example.

    Then you have to enable the module within drupal, and possibly clear the cache before the for alter will work.