Create User Cart upon Register with life cycle hook on User

System Information
  • Strapi Version: 3.1.0-alpha.5
  • Operating System: Windows 10 Pro Build 19041.630
  • Database: Mongo Atlas
  • Node Version: v12.18.3
  • NPM Version: 6.14.6
  • Yarn Version: 1.22.5

I started using Strapi CMS recently to create a server for my Flutter E-Commerce project. I wanted to generate cart_id beforeCreate of a user registration but couldn’t find the user.js file in my Strapi version. Strapi directory The User collection was automatically created with Strapi. User Collection image Could anyone help me out with this?


users-permissions lifecycle are located inside the node_modules:

To add custom lifecycles you should use extensions, create a file under:
extensions/users-permissions/models/User.js with content:

'use strict';

 * Lifecycle callbacks for the `User` model.

module.exports = {
 lifecycles: {
    // Called before an entry is created
    beforeCreate(data) {
        //do your magic here. 

Thanks Buddy

1 Like

Perfect question and a perfect answer… Thank you!!!

Can i get the password from here?