Email Change Confirmation module -- Avoid confirmation email from user_login hook 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' =&gt; '&lt;new address&gt;']);


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?
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' =&gt; '']);
  user_save($user, ['mail' =&gt; '&lt;new address&gt;']);


does the trick.