backend/src/bootstrap/user-subscribe.ts (view raw)
1import sendgrid from "../lib/sendgrid";
2
3export default async ({ strapi }) => {
4 strapi.db.lifecycles.subscribe({
5 models: ["plugin::users-permissions.user"],
6
7 async afterCreate({ result }) {
8 if (result.email) {
9 await sendgrid.subscribe(result.email);
10 strapi.log.info(
11 `New user with email address ${result.email} subscribed to mailing list`
12 );
13 }
14 },
15 });
16};