Copied to clipboard

Flag this post as spam?

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


  • HG 2 posts 72 karma points
    Oct 29, 2015 @ 15:11
    HG
    0

    v6.1.6 Get previous values for Member.BeforeSave Event?

    I'm looking to hook into the Member.BeforeSave event in order to send out e-mails when member passwords are changed from the back office.

    I struggled to find documentation, but between a couple of sources I've ended up with this:

    protected void Member_BeforeSave(Member sender, SaveEventArgs e)
    {
        var member = Member.GetCurrentMember();
    
        if (!member.Password. != sender.Password)
        {
            // send e-mail
        }
    }
    

    However, the changes appear to be already saved at this point. In my googling I found this to be an issue for Documents in earlier versions of Umbraco 4; is it still an issue for Members in 6.1.6?

    Any other suggestions on how to handle this? Is there another way (in 6.1.6) to detect if the password has been changed? I found some information for version 7 dirty properties, but we're a little way off upgrading unfortunately!

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Nov 02, 2015 @ 22:47
    Marc Goodson
    0

    HI HG

    Yes I think it was in 6.2 that the MemberService arrived to tidy this up.

    I think before that the underlying Membership Provider is maybe carrying out the save to the database before the Before and After events are being fired.

    So if an upgrade is not on the cards; it might be worth creating a custom UmbracoMembershipProvider, by inheriting from the existing one and overriding the ChangePassword functionality to see if this is indeed being used; and if so add the send email functionality or your own event to capture later on to send the email?

    regards

    Marc

  • HG 2 posts 72 karma points
    Nov 04, 2015 @ 08:42
    HG
    0

    Thanks for the confirmation Marc.

    If the fix is in 6.2 then it's worth having a conversation about upgrading, I was worried the answer was going to be 'upgrade to Umbraco 7' which we definitely can't handle right now.

    Looking at the 6.2 notes, it looks like the fix will be part of U4-1659, which also states that it's backwards compatible. That tallies with the upgrade guide which indicates nothing special needs to be done for a 6.2 upgrade, so I think we're pretty safe with this one.

    Thanks, it's good to know I can also hook in a custom membership provider if the upgrade doesn't work out.

Please Sign in or register to post replies

Write your reply to:

Draft