oalberto
09/08/2023, 9:19 AMif(notification.Content.ContentTypeAlias != Post.ModelTypeAlias)
return;
foreach (var variant in notification.Content.Variants)
{
var postAuthor = variant.Tabs.SelectMany(f => f.Properties)
.FirstOrDefault(f => f.Alias.InvariantEquals("author"));
if(variant.State != ContentSavedState.NotCreated)
return;
var loggedInUser = _backOfficeSecurityAccessor?.BackOfficeSecurity?.CurrentUser;
if (loggedInUser == null) return;
if (postAuthor != null)
{
postAuthor.Value = loggedInUser.Id;
}
}
If I do this with the ContentSavingNotification it works but I prefer to set the default so the Editor know that their user will be the author unless he/she change the value.Ambert
09/08/2023, 10:12 AMAmbert
09/08/2023, 10:12 AMAmbert
09/08/2023, 10:13 AMAmbert
09/08/2023, 10:14 AMoalberto
09/08/2023, 10:24 AMoalberto
09/08/2023, 9:48 PMoalberto
09/12/2023, 11:12 AMpostAuthor.Value = loggedInUser.Id.ToString();
A hub and casual space for you to interact with fellow community members and learn more about Umbraco!
Powered by