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

**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:** 5

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [2019年七月25日 18:54 UTC](https://meta.discourse.org/t/plugin-development-event-fired-if-email-address-is-changed/123899/5 "2019-07-25T18:54:57Z")

</div>

我觉得在 plugin.rb 中像这样写应该就可以了

```ruby
after_initialize do

  add_model_callback(UserEmail, :after_commit, on: :update) do
     # Group.add 等等
  end

end

```

---

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