Member.BeforeSave and Member.AfterSave events fire with same data
Hi all,
I need to have something where i have two versions of member property values:
Ones that existed before save occured (old values) - those that you can see when you open a member in backend.
And ones that exist after member is saved (new values) - those that somebody entered/edited in backend.
Here is how i expect the code to work:
public class EventExample : ApplicationBase
{
public EventExample()
{
Member.BeforeSave += new Member.SaveEventHandler(MemberBeforeSave);
Member.AfterSave += new Member.SaveEventHandler(MemberAfterSave);
}
private void MemberBeforeSave(Member sender, umbraco.cms.businesslogic.SaveEventArgs asgs)
{
//this is expected to fire with values of properties on sender that existed before user clicked save button in Umbraco backend.
}
private void MemberAfterSave(Member sender, umbraco.cms.businesslogic.SaveEventArgs asgs)
{
//this is expected to fire with new values of properties that will be saved to database.
}
}
Does anybody have any idea how can I make this work? Or maybe there are workarounds?
Hi. This behaviour is by implementation since when saving a member first the membership provider updates the database and only than before and after events are raised. If you need to access the initial member state when saving I think you could inherit UmbracoMembershipProvider and override the Update method so that to intercept database update.
Member.BeforeSave and Member.AfterSave events fire with same data
Hi all,
I need to have something where i have two versions of member property values:
Does anybody have any idea how can I make this work? Or maybe there are workarounds?
Hi. This behaviour is by implementation since when saving a member first the membership provider updates the database and only than before and after events are raised. If you need to access the initial member state when saving I think you could inherit UmbracoMembershipProvider and override the Update method so that to intercept database update.
Hello,
Rodion is right. Have a look at this blog: http://www.aaron-powell.com/the-great-umbraco-api-misconception.
Even in the before save event the data has already been saved to the database. This will probably be fixed in Umbraco 5.
Jeroen
Thanks, for replys.
I suspected something similar. These event work fine with Documents but not so well with Members.
I will probably rely on Rodion's workaround/hack for this.
is working on a reply...