Drupal 在Ubercart结帐页面中询问两次电子邮件
是否有Ubercart模块要求用户在结帐页面中插入电子邮件两次?我怀疑是否有此模块。您可以在自定义模块中使用Drupal 在Ubercart结帐页面中询问两次电子邮件,drupal,drupal-6,ubercart,Drupal,Drupal 6,Ubercart,是否有Ubercart模块要求用户在结帐页面中插入电子邮件两次?我怀疑是否有此模块。您可以在自定义模块中使用hook\u form\u alter执行此操作。应该只有10-20行代码 差不多 function module_form_FORM_ID_alter(&$form, &$form_state) { $form['...']['second_mail'] = array( '#title' => t('Verify E-mail'), '#typ
hook\u form\u alter
执行此操作。应该只有10-20行代码
差不多
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');
}
}
上面是示例代码,但实际上可能会起作用,这取决于ubercart签出表单的创建方式,更具体地说,取决于其邮件字段的名称
虽然有一些空白,但填写起来应该很容易。我使用以下方法来完成:
/* Code to add confirm email for uc checkout */
function custom_code_form_alter(&$form, $form_state, $form_id) {
if($form_id == "uc_cart_checkout_form" && $form['panes']['customer']['primary_email']['#type'] != 'hidden'){
$form['panes']['customer']['primary_email']['#weight'] = '0';
$form['panes']['customer']['new_account']['#weight'] = '2';
$form['panes']['customer']['confirm_email'] = array(
'#title' => t('Verify E-mail address'),
'#type' => 'textfield',
'#size' => '32',
'#required' => true,
'#weight' => '1'
);
$form['#validate'][] = 'custom_code_validate_confirm_email';
}
}
function custom_code_validate_confirm_email(&$form, &$form_state){
if($form_state['values']['panes']['customer']['primary_email'] != $form_state['values']['panes']['customer']['confirm_email']) {
form_set_error('panes[customer][confirm_email', t('Email addresses must match.'));
}
}
/* end code for confirm_email */
ubercart签出设置中有一个电子邮件确认复选框。不需要额外的模块