Problem

If, as a registered user, I subscribe to an EMF list, this subscription will use my account's email address. But when I update my account to change my email address, my subscriptions will not be updated. Not locally (in the {emf_subscription} table and neither at the service.

Note that Campaign Monitor and MailChimp both have API functions to update the email address of an already subscribed user.

Proposed resolution

On user account update (ie. hook_user_update) and for each list the user is subscribed to, detect if the subscription information need to be updated. If yes, enqueue a request to update the information.

Detecting if a the subscription information need to be updated can be tricky, so a hook could be provided to let any module do the job.

See the user_update_1180246 branch.

Remaining tasks

Define a proper API to update information of an already subscribed user for a given list.

API changes

New hook: hook_emf_account_subscription_requires_update() to let any module detect if the user subscription information require an update.

Original report by [username]

Hello everyone,

I'm currently working on the data's synchronisation between drupal and the mails services( like the user's account detail or change and update the user's email).
And I have create a patch for this. And I need your reviews.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

remeizs’s picture

Sorry I forget to tell you something : this update and the synchronisation issues work only for the mailchimp services. ( I think it's not difficult for the campaign monitor)
I forget to add a row "fields" for the emf_subscription table.

Here's the patch.

remeizs’s picture

This is the final patch for mailchimp services (because the previous was incomplete).
Please review this :

pbuyle’s picture

Does this patch only pushes the change from Drupal to the mail service, or does it also pull updates from there?

PS: I closed #1146492: When a user's information are updated, the changes are not pushed to the service as duplicate of this issue.

remeizs’s picture

It can push the changes from Drupal to Mailchimp and it can also pull updates from there.
If you're having a problem. You can contact me anytime.

PS : Apply the final patch that I posted because the two previous patch i forgot to call the function which pull updates from mail services.
I have worked only on the mailchimp and not on the campaign monitor. But it's not difficult to configure it.

remeizs’s picture

Please review

remeizs’s picture

up?

pbuyle’s picture

I'm currently not working with the D6 branch and I don't have much time to dedicate to this, but here are some remarks:

  • The patch removes changes commited in http://drupal.org/node/1145704#comment-4444020 (fails count). Is this done on purpose?
  • Could you describe the API changes and the implemented sync. mechanism? This would help me and other to understand the code.
  • This is a complicated feature, have a SimpleTest would probably help to get it right and ensure no future regression. There is currently no test infrastructure for the D6 branch, but the one I made for the D7 branch could be easily backported (I guess).
pbuyle’s picture

Version: 6.x-1.4 » 7.x-1.x-dev
Status: Needs review » Needs work

I need this feature in Drupal 7 and since no one seems to be actively working on it for Drupal 6, I retarged the issue.

I implemented a rather dumb and crude solution to update user information on user account update. I added a hook to EMF: hook_emf_account_subscription_requires_update() to allow any module trigger the update of a user subscription. Implementations of this hook are called from emf_user_update() for each EMF list. If any module implementation returns true, the user subscription for the list is updated. EMF itselft should implementshook_emf_account_subscription_requires_update().

Because EMF and the existing plugins don't have an API to update a subscription, to update his subscription the user is unsubscribed from the list and added back.

The properly implement the update and complete the issue, we should work an subscription/list member update API for EMF, so plugins could implement a proper solution (ie. for instance, using the listUpdateMember() method for the MailChimp plugin).

This is commited in the user_update_1180246 branch.

pbuyle’s picture

remeizs, can you confirm that your patch included an API to update the information for an already subscribed user?

pbuyle’s picture

Issue summary: View changes

Proposed solution as implemented in a dedicated branch.