-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug/double opt in triggered despite being disabled in settings #115
base: develop
Are you sure you want to change the base?
Bug/double opt in triggered despite being disabled in settings #115
Conversation
Remove the user status from double opt-in since it's not clear that logic affects why a user should receive a confirmation email or not
…sting user check get_option( 'mc_update_existing' ) returns '1' or '', but never false
…g subscribers is off
// If update existing is turned off and the subscriber is not new, error out. | ||
$is_new_subscriber = false === $status; | ||
if ( ! get_option( 'mc_update_existing' ) && ! $is_new_subscriber ) { | ||
$msg = esc_html__( 'This email address has already been subscribed to this list.', 'mailchimp' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If "Update Existing Subscriber?" is disabled and the email does not belong to a new subscriber then don't let them sign up.
The previously functionality only checked for emails with a subscribed
status. This missed unsubscribed
, pending
, and the other possible Mailchimp statuses.
unsubscribed
and pending
users as well? If we don't update unsubscribed
users then it will be functionally impossible for any user to resubscribe once unsubscribed. This directly relates to #93.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do think we'll want to allow other statuses to work here besides just subscribed
. As a user, I think I'd consider it a bug if someone that has unsubscribed can't resubscribe if that setting is on. The way I think this should work is if someone is subscribed or is in a pending state (I would assume that means they subscribed but haven't verified that yet), we shouldn't allow them to resubscribe if this option is enabled. But if they have never subscribed or if they have unsubscribed, they should be allowed to subscribe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way I think this should work is if someone is subscribed or is in a pending state, we shouldn't allow them to resubscribe if this option is enabled
mc_update_existing
I 100% agree with you.
- In the case of
subscribed
, the sign up request will update the existing contact instead of creating a duplicate. - In the case of
pending
(subscribed, but haven't verified), their information will also be updated. However, the user must still confirm the email before the contact is created. The exception to this is if single opt-in has been enabled then thepending
contact will be created immediately without needing to verify the original email.
[If
mc_update_existing
is enabled or disabled] But if they have never subscribed they should be allowed to subscribe
Yes! Current functionality.
[If
mc_update_existing
is disabled] If they have unsubscribed they should be allowed to subscribe
I agree as well. The current Mailchimp functionality is that contacts can not be resubscribed through the API. However, there's a solution in #117 to still address this scenario.
I added a comment directly after "Update Existing Subscriber?" check to make an API request for the native Mailchimp sign up form if the contact has a status of unsubscribed and "Update Existing Subscriber?" is enabled.
Lines 916 to 917 in 8e1e3f4
// TODO: If get_option( 'mc_update_existing' ) && 'unsubscribed' === $status then | |
// make an API request to fetch Mailchimp hosted sign up form and display to user |
Some of the logic around setting a subscribers status as well as what type of subscribers should be allowed to update their contact info in Mailchimp are a bit hard to remember. I think those would be good candidates for unit tests. What does everyone else think? |
I'm fine with adding unit tests here |
Update on the unit tests. I've been prioritizing wrapping up other in progress tickets. The unit tests may not be ready before I move onto another project next week. |
Description of the Change
This PR bundles a two related issues.
Closes #113
Closes #114
How to test the Change
Double Opt-In triggered despite being disabled in settings
double-opt-in-triggered-despite-being-disabled-testing.mp4
If Double Opt-In is enabled and a
pending
user tries to update their information, then their status will still bepending
and they will have to confirm the original confirmation email (bug fix/logic change)Previously, the conditional check was attempting to skip Double Opt-in for any emails with an existing status.
double-opt-in-enabled-with-pending-user.mp4
Fix: Existing subscriber could sign up even if "Update Existing Subscriber?" is turned off
update-existing-subscriber-is-off-should-prevent-subscriber-from-signing-up-multiple-times.mp4
If "Update Existing Subscriber?" is disabled and the email does not belong to a new subscriber then don't let them sign up (changed logic)
Previously, the conditional check would only check for
subscribed
emails to throw an error. Now, any existing email type will throw the error.existing-emails-can-not-signup-if-update-existing-subscribers-is-not-enabled.mp4
subscribed
- Sign up with an already subscribed email on the FE submission form. You should see "This email address has already been subscribed to this list."unsubscribed
- Sign up with an email that has been unsubscribed from this list. You should see "This email address has already been subscribed to this list."pending
- Try signing up again with the email. You should see "This email address has already been subscribed to this list."Other statuses include
cleaned
,transactional
, andarchived
, but I don't think we need to worry about testing those.Changelog Entry
Credits
Props Nathan Tetzlaff, @MaxwellGarceau, pluckvermont.
Checklist: