1

I'm using the "Email Change Confirmation" (email_confirm) module with Drupal 7. It works well. However, I also have a user_login hook that sets certain users' email addresses, thus:

    user_save($user, ['mail' => '<new address>']);

In this instance, I want the change to take effect immediately, without the need for confirmation (via email or otherwise). The module already provides a configuration option to override sending a confirmation email when the address is changed via the interface by users with specified roles. I want it to behave like that when I change it via the login hook. Is there a way to override sending an email in this case?

1

After looking at the email_confirm code, I came up with a simple solution. A confirmation message isn't sent if an email address is changed to or from empty, so:

  user_save($user, ['mail' => '']);
  user_save($user, ['mail' => '<new address>']);

does the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.