summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Carleton-Barnes2013-01-28 19:14:37 (GMT)
committer Gabriel Carleton-Barnes2013-01-28 19:14:37 (GMT)
commitd0f869bbd7fcc8c048e1b2b8a1fea55b68d4288f (patch)
treeb22bd176ff5de7f214e0e9a54ab866e2ada88f36
parentee2ca28ad5f2eeef8d6f1ef9f08305c7be6d8212 (diff)
Added option to default registration form mailing list option to opt-in as requested in #1452330
-rw-r--r--modules/mailchimp_lists/mailchimp_lists.admin.inc13
-rw-r--r--modules/mailchimp_lists/mailchimp_lists.module7
2 files changed, 18 insertions, 2 deletions
diff --git a/modules/mailchimp_lists/mailchimp_lists.admin.inc b/modules/mailchimp_lists/mailchimp_lists.admin.inc
index 45c96f8..e03df72 100644
--- a/modules/mailchimp_lists/mailchimp_lists.admin.inc
+++ b/modules/mailchimp_lists/mailchimp_lists.admin.inc
@@ -159,6 +159,18 @@ function mailchimp_lists_list_form($form, &$form_state, $list = NULL) {
),
),
);
+ $form['list_settings']['settings']['default_register_form_optin'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Default to opt-in on registration form.'),
+ '#description' => t('This will only apply for lists appearing on the register form.'),
+ '#default_value' => isset($list->settings['default_register_form_optin']) ? $list->settings['default_register_form_optin'] : FALSE,
+ '#states' => array(
+ // only show for optional lists
+ 'visible' => array(
+ ':input[name="list_type"]' => array('value' => MAILCHIMP_LISTTYPE_OPTIONAL),
+ ),
+ ),
+ );
$form['list_settings']['settings']['show_account_form'] = array(
'#type' => 'checkbox',
'#title' => t('Show Subscription Options on User Edit Screen'),
@@ -442,6 +454,7 @@ function mailchimp_lists_list_form_submit($form, &$form_state) {
$form_state['values']['mergefields'] : NULL,
'doublein' => $form_state['values']['doublein'],
'show_register_form' => $form_state['values']['show_register_form'],
+ 'default_register_form_optin' => $form_state['values']['default_register_form_optin'],
'show_account_form' => $form_state['values']['show_account_form'],
'include_interest_groups' => $form_state['values']['include_interest_groups'],
'interest_groups_label' => $form_state['values']['interest_groups_label'],
diff --git a/modules/mailchimp_lists/mailchimp_lists.module b/modules/mailchimp_lists/mailchimp_lists.module
index 169e3be..bd63e20 100644
--- a/modules/mailchimp_lists/mailchimp_lists.module
+++ b/modules/mailchimp_lists/mailchimp_lists.module
@@ -459,10 +459,13 @@ function mailchimp_lists_user_subscribe_form($form, &$form_state, $lists, $accou
function mailchimp_lists_auth_newsletter_form(&$form, $list, $account) {
// determine if a user is subscribed to the list
$is_subscribed = FALSE;
+ $default_subscribed = FALSE;
if ($account && $account->uid > 0) {
$is_subscribed = mailchimp_is_subscribed($list->mc_list_id, $account->mail);
}
-
+ else {
+ $default_subscribed = $list->settings['default_register_form_optin'];
+ }
// wrap in a div
$wrapper_key = 'mailchimp_' . $list->name;
$form[$wrapper_key] = array(
@@ -486,7 +489,7 @@ function mailchimp_lists_auth_newsletter_form(&$form, $list, $account) {
$form[$wrapper_key]['subscribe'] = array(
'#type' => 'checkbox',
'#title' => ($list->label) ? t($list->label) : t('Subscribe to the @newsletter newsletter', array('@newsletter' => $list->label)),
- '#default_value' => $is_subscribed,
+ '#default_value' => $default_subscribed || $is_subscribed,
'#description' => $list->description,
);
}