<p>You can also try <code>User::EVENT_BEFORE_SAVE</code>. I'm not sure that it's documented anywhere, or if it was added after Brad responded, but it might work too.</p>

<pre><code>use yii\base\Event;
use craft\elements\User
use craft\events\ModelEvent;

Event::on(
    User::class,
    User::EVENT_AFTER_SAVE,
    function(ModelEvent $event) {
        ...
    }
);
</code></pre>

CC BY-SA 4.0
2022-03-29T17:16:34.603Z
This worked for me, thank you!!
iamkeir
CC BY-SA 4.0
2018-12-18T16:14:48.790Z
2018-12-18T16:14:48.790Z
Levi Nelson
<p>There aren't specific User element save events in Craft 3, but you can listen to <code>EVENT_AFTER_SAVE_ELEMENT</code> and check if the element is a user like so:</p>

<pre><code>Event::on(\craft\services\Elements::class, \craft\services\Elements::EVENT_AFTER_SAVE_ELEMENT, function(Event $event) {
    if ($event-&gt;element instanceof \craft\elements\User) {
        // Do your thing.
    }
});
</code></pre>

<p>For user activation, there's <code>EVENT_AFTER_VERIFY_EMAIL</code>:</p>

<pre><code>Event::on(\craft\services\Users::class, \craft\services\Users::EVENT_AFTER_VERIFY_EMAIL, function(UserEvent $event) {
    $user = $event-&gt;user
});
</code></pre>

CC BY-SA 4.0
2019-02-27T16:14:59.307Z
Thanks, this was helpful, it gave me an error for function(UserEvent $event), I changed it to function(Event $event)
Brad
CC BY-SA 4.0
2018-07-04T21:05:53.467Z
2018-07-04T21:05:53.467Z
Brad Bell
<p>How do I capture user events in Craft 3? I looked at the documentation but couldn't figure it out. I need to capture after user registration events and after user save events. </p>

<p>Here is what I tried, I know it's not correct but I think I'm pretty close</p>

<pre><code>Event::on(
    Users::class,
    Users::EVENT_AFTER_USER_SAVE,
    function (PluginEvent $event) {
        // do something
    }
);
</code></pre>

<plugin-development><craft3><events><usermodel>
User events in Craft 3
# User events in Craft 3

(Asked by: username_0 on 2018-07-04)

How do I capture user events in Craft 3? I looked at the documentation but couldn't figure it out. I need to capture after user registration events and after user save events. 
Here is what I tried, I know it's not correct but I think I'm pretty close
Event::on(
    Users::class,
    Users::EVENT_AFTER_USER_SAVE,
    function (PluginEvent $event) {
        // do something
    }
);

**Tags:** plugin-development, craft3, events, usermodel

---

## 2 answers

### Answer by username_3 on 2018-07-04. Score: 12 | Accepted answer

There aren't specific User element save events in Craft 3, but you can listen to EVENT_AFTER_SAVE_ELEMENT and check if the element is a user like so:
Event::on(\craft\services\Elements::class, \craft\services\Elements::EVENT_AFTER_SAVE_ELEMENT, function(Event $event) {
    if ($event->element instanceof \craft\elements\User) {
        // Do your thing.
    }
});

For user activation, there's EVENT_AFTER_VERIFY_EMAIL:
Event::on(\craft\services\Users::class, \craft\services\Users::EVENT_AFTER_VERIFY_EMAIL, function(UserEvent $event) {
    $user = $event->user
});

> **Comments:**
> **username_4**: Thanks, this was helpful, it gave me an error for function(UserEvent $event), I changed it to function(Event $event)  

---

### Answer by username_1 on 2018-12-18. Score: 4

You can also try User::EVENT_BEFORE_SAVE. I'm not sure that it's documented anywhere, or if it was added after Brad responded, but it might work too.
use yii\base\Event;
use craft\elements\User
use craft\events\ModelEvent;

Event::on(
    User::class,
    User::EVENT_AFTER_SAVE,
    function(ModelEvent $event) {
        ...
    }
);

> **Comments:**
> **username_2**: This worked for me, thank you!!  

---

