Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • mikkel 143 posts 365 karma points
    Aug 21, 2019 @ 18:29
    mikkel
    0

    Services.MemberService.GetMembersByMemberType("Member");

    I am stuck. I try to get data from the member who is logged in to his profile. he is supposed to be able to see his own data. but with the code I came up with, I get the same member no matter what member I log in with What i am doing wrong?

    @{ var test = Services.MemberService.GetMembersByMemberType("Member"); foreach (var item in test) {

    @item.Name
    <br />
    @item.ContentTypeAlias
    <br />
    
    @item.Email
    <br />
    
    @item.GetValue("address")
    

    } }

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Aug 21, 2019 @ 19:35
    Marc Goodson
    1

    Hi Mikkel

    Do you mean to show the current logged in Members details to them?

    You could use the MembershipHelper to pull back the details of the current logged in Member, represented as IPublishedContent, eg

    @{ var currentMember = Members.GetCurrentMember(); var someProperty = currentMember.Value

    if that helps?

    Your Services.MemberService.GetMembersByMemberType("member") is returning all members rather than the current logged in one.

    regards

    Marc

  • mikkel 143 posts 365 karma points
    Aug 23, 2019 @ 18:54
    mikkel
    0

    Hi Marc Goodson Yep that is what i meanπŸ™‚ I Will try that solution to πŸ™‚

  • Tarik 196 posts 840 karma points c-trib
    Aug 22, 2019 @ 11:19
    Tarik
    0

    I suggest two ways to get custom member property.

    1. Use GetCurrentMember() as Marc mentioned.
    2. Use GetCurrentMemberProfileModel() mentioned by Sebastiaan.

    Make sure you checked Member can edit permission.

    enter image description here

    Code:

     var currentMember = Members.GetCurrentMember(); 
     var member = Members.GetCurrentMemberProfileModel();
     var selectProperty = currentMember.Value("address");
    
    <div class="ui teal image label">
      @selectProperty
      <i class="delete icon"></i>
    </div>
    
    <div class="dividder">
        </div>
    <br/>
    <br/>
         foreach (var item in member.MemberProperties)
    {
    <div class="ui teal image label">
         <i class="info icon"></i>
      @item.Name
      <div class="detail">@item.Value</div>
    
    </div>
    }
    

    Result: enter image description here

  • mikkel 143 posts 365 karma points
    Aug 23, 2019 @ 18:52
    mikkel
    0

    Hi abuabdellah. Sorry for my late answer, i study alot at the moment πŸ™‚ I have tryit both virabels but i havent checket the Member can edit permissions. What are they doing ?? πŸ™‚

  • Tarik 196 posts 840 karma points c-trib
    Aug 24, 2019 @ 09:12
    Tarik
    0

    Peace be upon those who follow guidance, mikkel

    The description is mentioned on the image I posted, in short I see to use way 1 if you want to just display custom properties.

    Use way 2 to update custom properties.

    Addition to my previous code:

    item.Value = "Tarmigte";
    Members.UpdateMemberProfile(member);
    
Please Sign in or register to post replies

Write your reply to:

Draft