User Hooks

User Module


The user module comes with the following hooks. You can hook into those using the usual listener logic.

Please view the hook section in the Core module.

UserIsCreating

UserIsUpdating

The UserIsUpdating has one more method:

  • getUser(): Will return the user being updated

UserIsCreating Example

To keep the example simple we're going to use an inline listener using a closure instead of a full class. Lets say you want to make sure the first and last names are using an upper case first letter, we could do this:

Event::listen(UserIsCreating::class, function (UserIsCreating $event) {
    $attributes['first_name'] = ucfirst($event->getAttribute('first_name'));
    $attributes['last_name'] = ucfirst($event->getAttribute('last_name'));
    $event->setAttributes($attributes);
});

RoleIsCreating

RoleIsUpdating

The RoleIsUpdating has one more method:

  • getRole(): Will return the role being updated

Mobile Analytics