Member property not updating
# help-with-umbraco
m
Hi, In Umbraco v14.3 I'm trying to update a property as part of the member saved notification, but for some reason it's not saving. From my understanding the Notification is part of the pipeline and will be saved when the notification code is done. This is What i have
Copy code
public async Task HandleAsync(MemberSavedNotification notification, CancellationToken cancellationToken)
{
        var siteSettings = _publishedContent.Content(SiteConstants.SiteSettings) as SiteSettings;

        foreach (var entity in notification.SavedEntities)
        {
            var dirty = (IRememberBeingDirty)entity;
            var isNewMember = dirty.WasPropertyDirty("Id");

            if (isNewMember)
            {
                double days = siteSettings.EmailVerificationValidDays == 0 ? 1 : siteSettings.EmailVerificationValidDays;
                entity.IsApproved = false;
                entity.SetValue(SiteConstants.EmailVerificationPropertyName, DateTime.Now.AddDays(days).ToString());
                await _memberManager.SendEmailVerificationLinkAsync(entity.Key);
                _logger.LogInformation("Verification process started for member {Name}, Email:  {Email}", entity.Name, entity.Email);
            }
            else
            {
                //perform any update checks if needed
            }
        }
}
So on this line
entity.SetValue(SiteConstants.EmailVerificationPropertyName, DateTime.Now.AddDays(days).ToString());
I expect the value to be set. Checking the back office i don't see anything as well as database.
SiteConstants.EmailVerificationPropertyName
is the correct value, checked in backoffice. Would it be possible for anyone to shed some light as to what I'm doing wrong please? Thanks in advanced
d
hi @MadhackerZA I think this notification is published after the member has been saved. I see there is also a MemberSavingNotification. Maybe that is the one you will need
m
Hi @dawoe21 , Thank you, I will give that a try
Hi @dawoe21 , Thanks that did the trick
11 Views