I’m currently working on a login portal for users on an Umbraco V16 site. For this, I’m using Umbraco’s built-in member functionality.
However, I’ve added some custom fields to the member document type, and these are reflected in the generated Member model, which indirectly inherits from IPublishedContent.
I’ve now set up the following using the IMemberManager:
public async Task<Member?> GetCurrentPublishedMemberAsync()
{
var identity = await _memberManager.GetCurrentMemberAsync();
if (identity != null)
{
IPublishedContent? member = _memberManager.AsPublishedMember(identity);
if (member != null)
{
if (member is Member castedMember)
return castedMember;
}
}
return null;
}
From what I remember, this setup used to work fine in V13, but unfortunately it no longer does.
Is there anyone who can help me with this?
It seems like the member is no longer of type Member.
I have come across the exact same situation when upgrading from 14.2 to 16.1 and your post helped solve my issue.
Unfortunately I don’t have a better solution, but I will keep an eye out here to see if there is one. I am intrigued as to why this functionality changed.
I would also love to know how you came up with your solution if you get time to explain.