Skip to content
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

Only subscribe users when $sync_member_fields fields have changed #23

Open
jjjjjjjjjjjjjjjjjjjj opened this issue Sep 30, 2016 · 3 comments

Comments

@jjjjjjjjjjjjjjjjjjjj
Copy link

I'm getting a lot of errors from MailChimp saying Recipient "[email protected]" has too many recent signup requests, since subscribe is firing on every onBeforeWrite() of a Member, and sometimes writes happen frequently.

Perhaps we could add something along the lines of this to onBeforeWrite()? To prevent API calls to MailChimp when nothing has changed.

$syncFields = array_keys(static::get_sync_member_fields());
$matches    = [0];

foreach ($syncFields as $field) {
    $matches[] = isset($changed[$field]);
}

if (!max($matches)) {
    return;
}
@camfindlay
Copy link
Owner

Happy to review a pull request if you can put it together. Would be also good to have a test to check this 👍

@jjjjjjjjjjjjjjjjjjjj
Copy link
Author

Appreciate the immediate response! I'll look into it.

@camfindlay
Copy link
Owner

You are very welcome @janneklouman

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants