How to use Lifecycle hooks with strapi-admin User model?

Hi,

I would like to validate the domains of the users’ emails when they are created. (In admin/settings/users)

To do this, I was thinking of using lifecycle hooks.

But how to use lifecycle hooks with the model strapi-admin/models/User.js ?

Thank you in advance for your help :slight_smile:

System Information
  • Strapi Version: v3.5.0
  • Operating System: Mac OS 11.2.1
  • Database: Mariadb
  • Node Version: v14.15.4
  • NPM Version: 6.14.10
  • Yarn Version: 1.22.10

module.exports = {
lifecycles: {
afterCreate(result, data){
let email=result.email;
//write something
},
},
};

For more details you can read throw
https://strapi.io/documentation/developer-docs/latest/concepts/models.html#concept