Strapi and lifecycle hooks
May 24, 2021
Lately I was working on a project using Strapi headless CMS. The project has a collection type model call Profile which has a 1-to-1 relation with the User Permission plugin:
I wanted to automatically create a Profile during the user registration process. Instead of extending the User Permission plugin, I decided to use the lifecycle hooks to create the Profile.
Here is how I implemented the lifecycle hooks. I added the User.js file in the ./extensions/users-permissions/models folder with the following content:
'use strict';