I'm thinking a hook for changing the primary email would be helpful.

Here's a use case I'm facing:

  • Using a module that takes action when $user->mail is changed. In my case, user_mailman_register to manage mailing list subscriptions.
  • Would be useful to have a hook that provided the old primary address (or eid) and the new primary address (or eid).

I know I can use multiple_email_load_addresses() to get all addresses, then compare to see which is the old / new, but that's cumbersome and antithetical to the idea of an API.

Comments

kentr’s picture

Though, I also see that it might add some overhead. Looks like a call to user_load() and / or a query to {multiple_email} may be required in multiple_email_make_primary().

Let me know... I may be able to provide a patch, but I won't put effort into it unless you're on board with the idea.

kentr’s picture

Title: Hook to process "make primary" ? » Pass current $account to user_save() in multiple_email_make_primary()
Category: feature » bug
StatusFileSize
new1.25 KB

Just noticed that this would all work via HOOK_user() if the current account info were passed into user_save().

So, I'd call this a bug...

How about modifying multiple_email_primary_form_submit() and multiple_email_make_primary() to pass the value for $account?

As far as I can tell multiple_email_make_primary() is only called in that one place, so this change has zero chance of side effects within multiple_email itself.

shawn dearmond’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Patch (to be ported)

I like it.

Can we get it into 7.x first? The patch should be almost identical.

kentr’s picture

Sure.

Though, I don't use D7, so I can't roll a patch or test it.

Taxoman’s picture

Category: bug » feature
kentr’s picture

Category: feature » bug

What's the point of changing it to a feature request?

Technically, it's an oversight in the use of the Drupal API. It's not a missing feature.

Georgique’s picture

Status: Patch (to be ported) » Needs review
StatusFileSize
new1.27 KB

Attaching ported patch

drumm’s picture

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

I actually think 7.x looks okay. It does use user_load() properly. Calls to user_load() are cached, so it isn't a problem to over-call it. I think the D6 version should follow D7's lead and not introduce a new parameter.

drumm’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

D6 is no longer maintained.