H there!
Strapi v4 on board.
Im’ creating an user via
some custom controller
const userData = {
someField: "tryam"
}
Object.assign(ctx.request.body, userData);
return await strapi
.plugin("users-permissions")
.controllers.auth.register(ctx, next);
Also I catch the User AfterCreate hook and create the User Profile
the User & Permissions life cycle
plugin.contentTypes.user.lifecycles = {
async afterCreate(event) {
const { result } = event;
...
const profile = await strapi.entityService.create(
"api::profile.profile",
{
data: {
name: result.username,
user: result,
someField: result.someField,
publishedAt: new Date().getTime(),
},
}
);
All works fine except passing someField. The plugin U&P sanitizes my data. Is there a workaround?
I don’t need to create a filed in the User collection only in the Profile collection.
Cheers!