Copied to clipboard

Flag this post as spam?

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


  • Jan Molbech 40 posts 126 karma points
    May 02, 2014 @ 13:12
    Jan Molbech
    0

    Getting member by its ID

    How do I do this, since there aren't a GetMemberById Method available. The member aren't logged in.

    I get their Id from a cardscanner

    Umbraco Version 6.1.6

  • Dan 1288 posts 3921 karma points c-trib
    May 02, 2014 @ 14:17
    Dan
    100

    Hi Jan,

    Something like this should work:

    var memberId = 123;
    Member yourMember = new Member(memberId);
    
  • Jan Molbech 40 posts 126 karma points
    May 02, 2014 @ 14:49
    Jan Molbech
    0

    That works, but what happens if I supply a memberId that doesn't exist? I find it hard to get proper documentation for these methods

  • Dan 1288 posts 3921 karma points c-trib
    May 02, 2014 @ 14:52
    Dan
    0

    Great, glad that worked. I think in the case of no member being found with the id supplied 'yourMember' would be null. So you can do a check on that before you run any subsequent code.

    Regarding documentation, yep, same here, but things have improved in 6.2/7.1 where there's a brand new member API which has some new documentation. Possibly worth upgrading to 6.2 if you're going to be doing a lot of membership API stuff, although I've not tried it myself yet (the other new APIs e.g. the new Content Service, are much better though). The old membership documentation is here in case you'd not come across it http://our.umbraco.org/documentation/Reference/Management/MembershipProviders/, but it is definitely lacking detail. Feel free to keep posting on 'Our' though if you have any other specific questions and can't find the documentation - it's likely that someone can ease the frustration. :)

Please Sign in or register to post replies

Write your reply to:

Draft