I have been developing some plugin code for my registration form in Craft 3.

The event will be EVENT_AFTER_SAVE_ELEMENT, but I do not know how to detect if it is a new user or not. In Craft 2, the way was if ($event->params['isNewUser']).

It would be grateful for me if someone tell me how to do it.


In Craft 3 you would do:

    function(Event $event) {
        if ($event->element instanceof \craft\elements\User && $event->isNew) {
            // It's a new user 
  • Yes, your code works well. Thank you. – Kota.M Jul 2 '19 at 15:38
  • Thankfully I found this one my second search, works perfect! – mcclaskiem Dec 6 '20 at 18:52

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.