Getting profile data from members linked with member Picker
Using Umbraco version 7.6.4
Hi everyone,
Would anyone be able to offer some advise regarding the membershipHelper?
I have 2 types of members, one for Companies and one for Individuals, the Individuals have a member picker property on them so I can select the Company member record they are linked to.
I'd like to get to the company profile data to show in the view when the individual is logged in. I have done this previously using umbraco.cms.businesslogic but can't figure out a way to do this in the latest version of umbraco.
Previously i used:
var individual = umbraco.cms.businesslogic.member.Member.GetCurrentMember();
var companyid = (individual.GetProperty<int>("Company"));
umbraco.cms.businesslogic.member.Member company = new umbraco.cms.businesslogic.member.Member(companyid);
I can get the Individuals data but i'm not sure of the best way to get the linked companies data, here's the code I have:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.Dashboard>
@using ContentModels = Umbraco.Web.PublishedContentModels;
@{
Layout = "Master.cshtml";
var profileModel = Members.GetCurrentMemberProfileModel();
}
<h1>@Model.Content.Name</h1>
<h2>Get Members Standard Data</h2>
<p>get members login (UserId) = <strong>@profileModel.UserName</p></strong>
<p>get members last log in date = <strong>@profileModel.LastLoginDate</p></strong>
<p>get members email = <strong>@profileModel.Email</p></strong>
<h2>Get Members Profile Data</h2>
@foreach (var mp in profileModel.MemberProperties)
{
<p>Property Name: <strong>@mp.Name</strong> / Property Value: <strong>@mp.Value</strong></p>
}
<h2>Get Members associated Company Profile Data</h2>
Does anyone have any more info on this topic? I don't really understand why this change was made in the first place, members were pretty easy to work with before, but now that it is done it would be great if we had some idea how to use it. :D
Sorry to drag up an old thread - just hit this issue and took me a while to sort so hopefully this will help someone else.
Member has a picker called "memberPicker" where they pick a linked member. The GetValue returns the Udi - to get the member I needed the guid. This seems to work - if there's a cleaner way let me know!
var _umbracoMemberService = Services.MemberService;
var memberPickerValue = curMember.GetValue<GuidUdi>("memberPicker");
var otherMember = memberPickerValue != null ? _umbracoMemberService.GetByKey(memberPickerValue.Guid) : null;
Getting profile data from members linked with member Picker
Using Umbraco version 7.6.4
Hi everyone,
Would anyone be able to offer some advise regarding the membershipHelper?
I have 2 types of members, one for Companies and one for Individuals, the Individuals have a member picker property on them so I can select the Company member record they are linked to.
I'd like to get to the company profile data to show in the view when the individual is logged in. I have done this previously using umbraco.cms.businesslogic but can't figure out a way to do this in the latest version of umbraco.
Previously i used:
I can get the Individuals data but i'm not sure of the best way to get the linked companies data, here's the code I have:
Any help would be greatly appreciated.
Thanks Kerri
Hi Kerri,
Have you tried to use the approach that you will see in this documentation
https://our.umbraco.org/documentation/getting-started/backoffice/property-editors/built-in-property-editors/Member-Picker
Hope this helps you a step further.
/Dennis
Hi Dennis,
My member picker is not on a content page it is on another member type, i'm trying to link 2 members together
e.g Member 1 has these properties
relatedMember(memberPicker)
Member 2 has this property
companyName(textstring)
when I call
@foreach (var mp in profileModel.MemberProperties)
I get:I would like to know how to get the member profile for the RelatedMember id (d57524fef0554634b3582a93b2ab6215 in this example)
Thanks Kerri
I've still not figured this one out, can anyone else offer any suggestions?
Thanks! Kerri
Does anyone have any more info on this topic? I don't really understand why this change was made in the first place, members were pretty easy to work with before, but now that it is done it would be great if we had some idea how to use it. :D
Sorry to drag up an old thread - just hit this issue and took me a while to sort so hopefully this will help someone else.
Member has a picker called "memberPicker" where they pick a linked member. The GetValue returns the Udi - to get the member I needed the guid. This seems to work - if there's a cleaner way let me know!
Hi Steve,
We did it by creating a member helper in the end
Apologies for not sharing previously!
is working on a reply...