-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstant_contact.patch
52 lines (47 loc) · 1.76 KB
/
constant_contact.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
diff --git a/constant_contact.module b/constant_contact.module
index d490544..a2f0ae0 100755
--- a/constant_contact.module
+++ b/constant_contact.module
@@ -1099,7 +1099,6 @@ function constant_contact_signup_form($form, &$form_state, $delta)
return $form;
}
-
/**
* Custom signup form submit handler
*/
@@ -1178,25 +1177,30 @@ function constant_contact_signup_form_submit($form, &$form_state)
$lists = array_keys($lists);
if($contact):
- form_set_error('cc_email_'.$delta, t('Your email address is already subscribed'));
+ // SV: Old logic was to fail with error message if contact already exists.
+ // New logic is to continue without error and merge selected lists with
+ // those already assigned to contact. (Unselected lists are not removed
+ // from contact as this form is unprotected.)
+ $loaded_contact = $cc->get_contact($contact[id]);
+ $existing_lists = $loaded_contact['lists'];
+ $lists = array_unique(array_merge($lists, $existing_lists));
+ $status = $cc->update_contact($contact['id'], $user_email, $lists);
else:
$status = $cc->create_contact($user_email, $lists, $fields);
+ endif;
- if($status):
- if(!$redirect_to):
- drupal_set_message(t('Success, you are now subscribed to our mailing list'));
- endif;
- else:
- form_set_error('cc_email_'.$delta, t('Sorry, there was a problem, please ensure your details are valid and try again'));
+ if($status):
+ if(!$redirect_to):
+ drupal_set_message(t('Success, you are now subscribed to our mailing list'));
endif;
-
+ else:
+ form_set_error('cc_email_'.$delta, t('Sorry, there was a problem, please ensure your details are valid and try again'));
endif;
$form_state['redirect'] = $redirect_to;
return;
}
-
/**
* Cron job to handle syncing unsubscribers
*/