Strapi create new User (users-permissions plugin), lifecycles

Hi @Robert_Hlavica your solution worked for me as well.

I’m sharing here how I managed to benefit from afterCreate lifecycle hook to create a related entry, on a different content-type, upon user cretion. Even using the high level entityService class:

// src/extensions/users-permissions/content-types/user/lifecycles.js
module.exports = {
    // Creates an associated user-detail entry upon user account creation
    afterCreate(event) {
        strapi.entityService.create('api::user-detail.user-detail', {
            data: {
               nick: event.result.username,
               users_permissions_user: event.result.id,
               // This enforces user-detail as published, instead of just a draft
               // https://forum.strapi.io/t/creating-entry-from-controller-goes-to-draft/22501/2
               publishedAt: new Date().getTime()
           },
        });
    }
}