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 548 posts 1840 karma points MVP 3x 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

Please Sign in or register to post replies

Write your reply to:

Draft