Files
LeafWeb/WebCms/EventHandlers/MemberRegistrationEventHandler.cs
T
2019-12-15 21:18:51 -05:00

29 lines
1.0 KiB
C#

using Hangfire;
using LeafWeb.WebCms.Services;
using Umbraco.Core;
using Umbraco.Core.Events;
using Umbraco.Core.Models;
using Umbraco.Core.Services;
namespace LeafWeb.WebCms.EventHandlers
{
// https://our.umbraco.com/forum/umbraco-7/using-umbraco-7/64185-Assign-new-members-to-member-group-upon-registration#comment-254768
public class MemberRegistrationEventHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
base.ApplicationStarted(umbracoApplication, applicationContext);
MemberService.Created += MemberService_Created;
}
private void MemberService_Created(IMemberService sender, NewEventArgs<IMember> e)
{
sender.AssignRole(e.Entity.Username, "Unverified");
sender.Save(e.Entity);
// Send Email
BackgroundJob.Enqueue<EmailNotificationService>(
email => email.SendVerifyMemberEmail(e.Entity));
}
}
}