function mailchimp_form_user_register_form_alter in Mailchimp 7
Implements hook_form_FORM_ID_alter(). Add newsletter fields to registration form.
File
- ./
mailchimp.module, line 18 - Mailchimp module.
Code
function mailchimp_form_user_register_form_alter(&$form, &$form_state, $form_id) {
$account = $form['#user'];
$category = $form['#user_category'];
if (variable_get('mailchimp_user_register', TRUE)) {
$account->roles = array(
2 => 'authenticated',
);
if (count(_mailchimp_get_available_lists($account)) > 0) {
// wrap in a fieldset
$form['mailchimp_lists'] = array(
'#type' => 'fieldset',
'#title' => t('Newsletters'),
);
$form['mailchimp_lists'][] = mailchimp_subscribe_auth_form(NULL, NULL, $account, FALSE);
}
}
}