Copied to clipboard

Flag this post as spam?

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


  • Khalid Aziz 6 posts 96 karma points
    Jun 28, 2017 @ 21:40
    Khalid Aziz
    0

    Retrieve a member's login by their email address

    I'm having trouble figuring out the best way to get a user's login/username inside a SurfaceController. Members.GetByEmail(model.Email) returns an IPublishedContent object that I can cast to Member (a generated model) but neither have the username on them.

    Can anyone point me in the right direction?

  • Frans de Jong 550 posts 1862 karma points MVP 5x c-trib
    Jun 29, 2017 @ 00:48
    Frans de Jong
    100

    You could do

    var member = Members.GetByEmail(Model.Email);
    var memberName = Membership.GetUser(member.Id).UserName;
    

    But I think this goes to the Database, so It could get you in trouble performancewise

    If you want the username for the currentLoggedInMember you could do:

    var currentMemberName = Members.GetCurrentLoginStatus().Username
    

    So it's important to know what you want to accomplish

    Frans

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies