createNewUser

The createNewUser hook is triggered when a new front end user registers on the website. It passes the ID of the new user and the data array as arguments and does not expect a return value.

Parameters

  1. int $userId

    Unique ID of the user.

  2. array $userData

    All values which have been submitted on the registration form. Be aware that the user ID is not contained in this array ($userData['id'] is empty).

  3. \Contao\Module $module

    The front end module instance executing this hook.

Example

// src/EventListener/CreateNewUserListener.php
namespace App\EventListener;

use Contao\CoreBundle\ServiceAnnotation\Hook;
use Contao\Module;
use Terminal42\ServiceAnnotationBundle\ServiceAnnotationInterface;

class CreateNewUserListener implements ServiceAnnotationInterface
{
    /**
     * @Hook("createNewUser")
     */
    public function onCreateNewUser(int $userId, array $userData, Module $module): void
    {
        // Do something …
    }
}

References