Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I've hooked into the Saving event on the MemberService (I have tried Saved event too) and under certain conditions I am setting a value on a custom property.
The problem is (having debugged the code) that after the value is set, the Saving event is being fired another 2 times with the same member and the value of the custom property is being overwritten the 3rd time with null.
I am calling the .Save() method and setting raiseEvents to false but I have also tried not having this save call at all.
Does anyone know of any reason why the event would be fired 3 times?
I did notice a while back there was a similar issue reported in the issue tracker, but that seems to have been resolved.
As always I'm open to the possibility that I may be doing something wrong.
Any help will be much appreciated.
Can you post some example code?
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
MemberService.Saving += MemberService_Saved;
private void MemberService_Saved(IMemberService sender, SaveEventArgs<IMember> e)
foreach (IMember member in e.SavedEntities)
if (member.IsNewEntity()) //This is a newly created member
Guid resetToken = Guid.NewGuid();
string setPasswordUrl = CreatePasswordUrl(resetToken.ToString(), member.Email);
EmailNewUser(member.Email, member.Name, setPasswordUrl);
You can ignore the fact that the event is Saving and the method is MemberService_Saved; this is because I've been trying different events but I haven't been renaming the method.
It's not the foreach going round 3 times is it? Saving the member each time for the e.SavedEntities.
No, there is only one saved entity, and it's the event which is being triggered 3 times with the same object as e each time
I think this topic reported the same issue: https://our.umbraco.org/forum/umbraco-7/using-umbraco-7/60408-MemberService_Saving-called-multiple-times
yep, looks like it, so definitely sounds like a bug.
I'll update the issue tracker and I'll implement a workaround in the meantime.
Thanks for the help Jeroen!
Got stuck here as well. Did you find a solution?
The post is old and I do not know if they have already fixed this bug. When I need to update member property in the event and do not want to fire the event again, I do so:
ApplicationContext.Current.Services.MemberService.Save (member, raiseEvents: false);
Set the raiseEvents variable to false in the method. Always worked
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted