Search code examples
drupaldrupal-6ubercart

Ask twice for email in the Ubercart checkout page


Is there a Ubercart module to ask the user to insert his email twice in the checkout page?


Solution

  • I doubt there is a module for this. You can do this with hook_form_alter in a custom module. Should only be 10-20 lines of code.

    Something like

    function module_form_FORM_ID_alter(&$form, &$form_state) {
      $form['...']['second_mail'] = array(
        '#title' => t('Verify E-mail'),
        '#type' => 'textfield',
        '#weight' => xx,
      );
    
      $form['#validate'][] = 'module_validate_function_name';
    }
    
    function module_validate_function_name(&$form, &$form_state) {
      if ($form_state['values']['mail'] != $form_state['values']['second_mail']) {
        form_set_error('second_mail', t('You have mistyped your e-mail, please verify');
      }
    }
    

    The above is example code, but might actually work, it depends how the ubercart checkout form is created, more specifically, the name of it's mail field.

    There are a few blanks but it should be easy enough to fill out.