Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Osman Coskun 170 posts 404 karma points
    Feb 12, 2018 @ 10:16
    Osman Coskun
    0

    Member Event Handler run only if the member update is made by member

    Hello,

    I use the following event handler to send a notification e-mail to newly registered members. The client needs to be informed when members update their profile. How can i separate the member update events made by members or by site administrators and send email to site administrator if member made a profile update?

     private void MemberService_Saving(Umbraco.Core.Services.IMemberService sender, Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IMember> e)
        {
            //custom code
            foreach (IMember member in e.SavedEntities)
            {
                if (member.HasProperty("memberApproved") && member.Properties["memberApproved"].IsDirty() && member.GetValue("memberApproved").ToString() == "1")
                {
                    MailMessage message = new MailMessage();
                    message.To.Add(member.Email);
                    message.Subject = "Subscription approved";
                    message.IsBodyHtml = true;
                    message.From = new System.Net.Mail.MailAddress("[email protected]", "Site Name");
                    message.Body = "Your member account is approved.";
                    SmtpClient smtp = new SmtpClient();
                    smtp.Send(message);
                }
    
            }
        }
    
Please Sign in or register to post replies

Write your reply to:

Draft