MailChimp Lists currently sends (or queues for sending) subscription information using hook_field_presave().

This is really too early in the process and hook_field_insert()/hook_field_update() would be the better place to perform this action.

Specifically things that don't work with the current approach:

  • Making alterations as part of hook_field_presave() in any module that would normally preceed it (by weight/name)
  • Making alterations as part of hook_entity_presave() as this is done after field hooks.
  • The same is true of events in Rules.

I'm not sure if there was a particular reason for doing it in hook_field_presave()?

Comments

andrewbelcher’s picture

Status: Active » Needs review
StatusFileSize
new1.46 KB

Here's a patch that does it.

Anonymous’s picture

Status: Needs review » Postponed (maintainer needs more info)

Hi,

Moving to the postsave hook is an interesting idea and we'll test it out, but we're not sure what the plan was in this patch, with the presave and update hook implementations calling the postsave hook. At first blush, it seems like just changing "pre" to "post" in the function name would be enough.

Thanks!

andrewbelcher’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new1.46 KB

Apologies, the patch was slightly wrong. It was supposed to be hook_field_insert() and hook_field_update().

There isn't a hook_field_postsave(), but rather the 2 separate ones for insert/update, so that's why the postsave is a separate function.

Anonymous’s picture

Assigned: Unassigned »

Ah, that makes sense. Thanks for the clarification and the updated patch; I'll test this out.

  • 6c1 committed f59e72e on 7.x-3.x authored by andrewbelcher
    Issue #2445867 by andrewbelcher: Use hook_field_update() rather than...
Anonymous’s picture

Assigned: » Unassigned
Status: Needs review » Closed (fixed)