Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1412 posts 3285 karma points c-trib
    May 16, 2017 @ 14:49
    Simon Dingley
    0

    MemberService.Deleted Not Fired

    Are there any known issues with wiring up Member event handlers? I had a look on the issue tracker and didn't notice anything relevant. The issue I have is that I need to hook into the MemberService.Deleted event but it doesn't appear to be firing.

    I have it wired up as follows:

    public class MyApplication : ApplicationEventHandler
    {
        private IMyMemberService _myMemberService;
    
        public MyApplication(IMyMemberService myMemberService)
        {
            this._myMemberService = myMemberService;
        }
    
    
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            MemberService.Deleted += MemberService_Deleted;
        }
    
        private void MemberService_Deleted(IMemberService sender, Umbraco.Core.Events.DeleteEventArgs<Umbraco.Core.Models.IMember> e)
        {
            var member = this._myMemberService.GetByUserId((int)e.DeletedEntities.FirstOrDefault().ProviderUserKey);
            this._myMemberService.Delete(member);
        }
    }
    

    Any ideas appreciated.

    Thanks

  • Alex Skrypnyk 5753 posts 21843 karma points MVP 4x admin c-trib
    May 16, 2017 @ 17:10
    Alex Skrypnyk
    0

    Hi Simon

    It looks like not related to your issue, but there are no docs about MemberService events in documentation section - https://our.umbraco.org/documentation/reference/events/

  • Asembli 47 posts 164 karma points
    Jan 13, 2020 @ 22:18
    Asembli
    0

    Hi,

    hm late reply, but anyway, I was looking for the same fn and must say that this excerpt worked for me (7.15.3)

        public class DashboardEventHandler : ApplicationEventHandler
    {
        public DashboardEventHandler()
        {
            MemberService.Deleted += this.MemberServiceDeleted;
        }
    
        private void MemberServiceDeleted(IMemberService sender, Umbraco.Core.Events.DeleteEventArgs<Umbraco.Core.Models.IMember> e)
        {
            IMemberService memberService = ApplicationContext.Current.Services.MemberService;
            foreach (var item in e.DeletedEntities)
            {
                // do something with member beeing deleted
                int memberId = item.Id;
            }
        }
    

    BTW if you work with Members section don't forget to include this patch: https://github.com/umbraco/Umbraco-CMS/issues/6283

    Regards, /Asembli

Please Sign in or register to post replies

Write your reply to:

Draft