# 插件开发-- 如果电子邮件地址更改，是否触发事件？

**URL:** https://meta.discourse.org/t/plugin-development-event-fired-if-email-address-is-changed/123899
**Category:** Development
**Created:** [2019年七月24日 23:06 UTC](https://meta.discourse.org/t/plugin-development-event-fired-if-email-address-is-changed/123899 "2019-07-24T23:06:51Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2019年七月25日 19:19 UTC](https://meta.discourse.org/t/plugin-development-event-fired-if-email-address-is-changed/123899/6 "2019-07-25T19:19:02Z")

</div>

太好了！IT 工作正常！

```plaintext
  self.add_model_callback(UserEmail, :after_commit, on: :update) do
    puts "#{'-'*50}\nEMAIL YES ADDRESS IS UPDATED for #{self.user_id}!!!!\n#{'-'*50}\n"
    user = User.find(self.user_id)
    GroupDomain.add_to_group_if_in_whitelisted_domain(user)
  end

```

非常感谢，@Falco！

---

_[View the full topic](https://meta.discourse.org/t/plugin-development-event-fired-if-email-address-is-changed/123899)._
