0

I am trying to request more information from users when they register for my site. I put a set-message in and it's not eve appearing nor any changes in the user register form.

I cant seem to find anything online to work, any help would be greatly appreciated. Thanks!

 <?php
       function hook_form_alter(&$form, &$form_state, $form_id){

         drupal_set_messge($form_id);

         if ($form_id == "user_register_form") {
              $form['account']['name']['#title'] = t('Full name');

              $form['city'] = array(
                '#type' => 'textfield', 
                '#title' => t('City'),
                '#size' => 15,
                '#required' => TRUE,
              );

              $form['state'] = array(
                '#type' => 'textfield', 
                '#title' => t('State'),
                '#size' => 15,
                '#required' => TRUE,
               );

               $form['#submit'][] = 'hook_from_alter_submit';

          }

     }

    function hook_form_alter_submit($form, &$form_state) {

       $city = $form_state['values']['city'];
       $state = $form_state['values']['state'];
    }

 ?>
1

The naming convention for hooks is:

MODULENAME_hook_name()

So to implement hook_form_alter() in a module called MYMODULE, your function would be defined as:

function MYMODULE_form_alter(&$form, &$form_state, $form_id) {
  // ...
}

Have a look at What is the basic concept behind hooks? for a more detailed explanation.

  • See the WSOD help guide: drupal.org/node/158043 – AyeshK Apr 29 '13 at 16:24
  • I changed that and I fixed the typo in the drupal_set_message and still nothing is showing up. File names are user_reg.info and user_reg.module and the functions are user_reg_form_alter and user_reg_form_alter_submit – tht1kid Apr 29 '13 at 17:49
  • Well the other person working on the site installed some random mail modules, and now the login works... Thanks! – tht1kid Apr 29 '13 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.