Did you get any progress on this?
I am trying with this:
module.exports = {
lifecycles: {
async afterCreate(result, data) {
try {
await strapi.services.profile.create({
user: result.id,
});
await strapi
.query("user", "users-permissions")
.update({ id: result.id }, { confirmed: false });
await strapi.notifications.toggle({
type: "info",
title: { id: "app.new.user.registered.notification.title" },
message: {
id: "app.new.user.registered.notification.message",
values: { email: result.email },
},
link: {
url: `${strapi.backendURL}/admin/plugins/content-manager/collectionType/plugins::users-permissions.user/${result.id}`,
label: {
id: "notification.see.more.link",
},
},
});
} catch (error) {
console.log("Error after registering new user: ", error);
}
},
};
But it produces the following error:
Error after registering new user: TypeError: Cannot read property 'toggle' of undefined
at Object.afterCreate (/srv/app/extensions/users-permissions/models/User.js:13:36)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async executeLifecycle (/srv/app/node_modules/strapi-database/lib/utils/lifecycles.js:11:5)
at async Object.create (/srv/app/node_modules/strapi-database/lib/queries/helpers.js:18:3)
at async Object.register (/srv/app/node_modules/strapi-plugin-users-permissions/controllers/Auth.js:492:20)
at async resolver (/srv/app/node_modules/strapi-plugin-users-permissions/config/schema.graphql.js:195:11)