Hello, I was looking for a solution to override the lifecycle hooks of existing content-type with a plugin. Like I am creating a page content-type inside Strapi (not inside a plugin) and I would like to change the beforeCreate() since a plugin. Is it possible ?
Found the answser
Just go inside ./src/plugins/[plugin-name]/server/index.ts and I did something like
register({ strapi }) {
const entity = "api::page.page";
const { lifecycles } = strapi.contentType(entity);
strapi.contentType(entity).lifecycles = {
...lifecycles,
async beforeUpdate() {
console.log("hello from plugin");
},
};
},
....
Works fine
1 Like