UserHasRegistered event not working.



  • Hi there,

    I am trying to extends the User module to add extra fields on Create New user page at backend. Along with First name, last name, password,confirm password, I want to add new fields like Designation, About user etc.

    So for this I have created one new module called UserProfile. But In my case UseHasRegistered event is not working. While updating users UseWasUpdated event is working perfectly. What could be the issue any guess?

    Can you please help me on this issue?


  • Global Moderator

    @deben

    Hey,

    There are two things going on.

    First UserHasRegistered is firing correctly, but you have to see where. The event you are looking for is firing when you fill out register form on frontend (auth/register).

    Second one from the admin(backend) when you create manually new user it has no event attached to it.

    If you want for event to fire also from backend manual creations you have to modify User module code.

    Assuming you are using default user driver (Sentinel):
    In Modules/User/Repositories/Sentinel/SentinelUserRepository.php change following function:
    from

        public function create(array $data)
        {
            return $this->user->create((array) $data);
        }
    

    to

         // include use Modules\User\Events\UserHasRegistered; at the top
    
        public function create(array $data)
        {
            $user = $this->user->create((array) $data);
            
            event(new UserHasRegistered($user));
    
            return $user;
        }
    

    Filled PR on Asgard User module


Log in to reply
 

Looks like your connection to AsgardCms was lost, please wait while we try to reconnect.