I migrate my project to Umbraco 9 and I need to get a Content, Member and Media by Udi. In Umbraco 8 the UmbracoHelper contains the method PublishedContent which do this exactly. In new Umbraco version access to members is moved to IMemberManager. IMemberManager contains also a method to convert the MemberIdentityUser object (which is returned by methods inside IMemberManager) to IPublisehdContent. However I don't how to get MemberIdentityUser object by Udi.
The best solution what I have been finding is using IIdKeyMap service. You need to inject IIdKeyMap to your class and use it some like that:
IPublishedContent publishedContent = null;
var memberAttempt = _idKeyMap.GetIdForUdi(nodeUdi);
if (memberAttempt.Success)
{
var memberId = memberAttempt.Result;
var member = await _memberManager.FindByIdAsync(memberId.ToString());
if (member != null)
{
publishedContent = _memberManager.AsPublishedMember(member);
}
}
How to get Member by Udi in Umbraco 9
Hello,
I migrate my project to Umbraco 9 and I need to get a Content, Member and Media by Udi. In Umbraco 8 the UmbracoHelper contains the method PublishedContent which do this exactly. In new Umbraco version access to members is moved to IMemberManager. IMemberManager contains also a method to convert the MemberIdentityUser object (which is returned by methods inside IMemberManager) to IPublisehdContent. However I don't how to get MemberIdentityUser object by Udi.
So how to get a Member by Udi?
Did you find a solution?
/Rune
The best solution what I have been finding is using
IIdKeyMap
service. You need to injectIIdKeyMap
to your class and use it some like that:Thanks Sebastian,
Weird that it's so awkward working with members. Must be because they are so integrated with the native .net member system.
I will see if your solution is useable in my situation 👍
/Rune
is working on a reply...