afterCreate in user-permissions plugin

System Information
  • Strapi Version: 3.5.4
  • Operating System: localhost (Mac OSX 11.2.2 (20D80))
  • Database: 10.5.6-MariaDB-1:10.5.6
  • Node Version: 14.6.1
  • NPM Version: 6.14.12
  • Yarn Version: 1.22.10

Good evening,

I hope this is the correct section for my problem. I have got a problem with the user-permissions plugin.

I have got users and companies. Every user can have many companies and one company can have many users. So I’ve got a many-to-many-relation. It was no problem to create a many-to-many-relation between users and companies. But now I have to add another field to the many-to-many-relation table named confirmed. After registration the field has to be set als 0. In my database I’ve added a new field confirmed with the data type TINYINT(1). Additionaly I have added some new fields to my users model, e.g. forename, lastname etc. This fields are perfectly saved in ./extensions/users-permissions/models/User.settings.json.

Now the problem: I wanted to create a file named User.js in ./extensions/users-permissions/models/ where I can add some logic for setting the field confirmed in my many-to-many-relation table. I have added something like this:

'use strict';

module.exports = {
  lifecycles: {
    // Called before an entry is created
    afterCreate(data) {
      return "Test1"

but nothing is fired. I don’t see the problem and I hope, someone can give me a hint.

Thank you!


Now I’ve tried the following in ./extensions/user-permissions/models/User.js:

'use strict';

 * Lifecycle callbacks for the `User` model.

module.exports = {
  lifecycles: {
    async beforeCreate(data) {
    async afterCreate(result, data) {

But there’s no log. I think the file will not be executed.

1 Like

Hi @thorsten, I have the same issue. Have you found a workaround?