The TaskLogic class (moved this outside the Umbraco evens for testing, when calling this from a controller it works):
public static void NewUser(int userId)
{
if (userId != 0)
{
// set key for new user so the user can create it's own password afterwards
var memberService = ApplicationContext.Current.Services.MemberService;
var member = memberService.GetById(userId);
if (member != null)
{
var randomGuid = Guid.NewGuid().ToString();
member.SetValue("passwordKey", randomGuid);
memberService.Save(member, false);
}
}
}
When saving the member in the backoffice the right events are triggered.
What is the correct way because my events got fired the way i was expecting but the setvalue didn't fire.
You set the value in the created event, but you check the value in the saved event. That's wrong because it's already saved. That needs to be in the saving event.
Also in the created event e.Entity.Id is probably always 0.
Umbraco 7 UmbracoEvents memberservice not working as expected
In my Umbraco installation I need to send a email when a new user is created. For that i'm using the Umbraco Events.
I have the following code:
Saved:
Created:
The TaskLogic class (moved this outside the Umbraco evens for testing, when calling this from a controller it works):
When saving the member in the backoffice the right events are triggered.
What is the correct way because my events got fired the way i was expecting but the setvalue didn't fire.
Hello,
You set the value in the created event, but you check the value in the saved event. That's wrong because it's already saved. That needs to be in the saving event.
Also in the created event e.Entity.Id is probably always 0.
Jeroen
Hi Jeroen, Thanks for your reply.
I changed the code a little bit in the way you suggested:
Saving event (removed the saved event):
The code is fired but when in look inside Umbraco the property is not filled in.
When debugging the code the process seems right to me. But the data is not present in the member section afterwards.
What is the correct way of doing this?
is working on a reply...