function ajax_register_form_alter in Ajax Login/Register 7.3
Same name and namespace in other branches
- 6.2 ajax_register.module \ajax_register_form_alter()
- 6 ajax_register.module \ajax_register_form_alter()
- 7.4 ajax_register.module \ajax_register_form_alter()
Implements hook_form_alter().
File
- ./
ajax_register.module, line 26
Code
function ajax_register_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'user_login_block':
$registration_allowed = variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);
if ($registration_allowed) {
$user_register_link = array(
'#type' => 'link',
'#title' => t('Create new account'),
'#href' => 'ajax_register/register/nojs',
'#id' => 'ajax_link',
'#attributes' => array(
'class' => array(
'use-ajax',
),
'title' => t('Create a new user account.'),
),
);
}
$user_password_link = array(
'#type' => 'link',
'#title' => t('Request new password'),
'#href' => 'ajax_register/password/nojs',
'#id' => 'ajax_link',
'#attributes' => array(
'class' => array(
'use-ajax',
),
'title' => t('Request new password via e-mail.'),
),
);
$items[] = render($user_register_link);
$items[] = render($user_password_link);
$form['links'] = array(
'#theme' => 'item_list',
'#items' => $items,
);
// No break here!
case 'user_login':
$form['messages'] = array(
'#markup' => '<div id="ajax-register-login-messages"></div>',
);
$form['actions']['submit']['#ajax'] = array(
'callback' => 'ajax_register_login_ajax_callback',
);
break;
case 'user_pass':
$form['messages'] = array(
'#markup' => '<div id="ajax-register-pass-messages"></div>',
);
$user_login_link = array(
'#type' => 'link',
'#title' => t('Back to login'),
'#href' => 'ajax_register/login/nojs',
'#id' => 'ajax_link',
'#attributes' => array(
'class' => array(
'use-ajax',
),
'title' => t('Back to login form.'),
),
);
$items[] = render($user_login_link);
$form['links'] = array(
'#theme' => 'item_list',
'#items' => $items,
);
$form['actions']['submit']['#ajax'] = array(
'callback' => 'ajax_register_pass_ajax_callback',
);
$form['#after_build'][] = 'ajax_register_user_pass_after_build';
break;
case 'user_register_form':
$form['messages'] = array(
'#markup' => '<div id="ajax-register-reg-messages"></div>',
);
$form['actions']['submit']['#ajax'] = array(
'callback' => 'ajax_register_register_ajax_callback',
);
break;
}
}