Copied to clipboard

Flag this post as spam?

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


  • snitram 27 posts 48 karma points
    Oct 12, 2010 @ 12:07
    snitram
    0

    Creating member programatically

    Hey,

    I'm working on my event calendar, and got very nice help on approaching the calender structure itself.

    I'm starting to implement the calendar, and I need members to be able to login on the website, to be able to register for an event.

    I've searched the forum, and I still don't understand how I'll be able to set custom properties on the members I create. I've created my own usercontrol, for creating the members because I need the members to be able to upload an Image, supply a Zipcode etc. Can anyone point me in the right direction?

    From what I could find on the forum, the following should work (simplified):

     

     

     

     

    MembershipUser user = myProvider.CreateUser(eMail, password, eMail, string.Empty, string.Empty, true, string.Empty, out createStatus);

    And then:

     

    Member m = Member.GetMemberFromLoginName(user.UserName);
    m.getProperty("Zipcode") = "9000";

    or

     

     

     

     

    ProfileBase profile = ProfileBase.Create(user.UserName);
    profile.SetPropertyValue(
    "Zipcode", "9000");

     

    Either way, the member is created correctly, but I get the "Object not set to an instance..." error, when I set the property value.

    Help? :-)

     

  • snitram 27 posts 48 karma points
    Oct 12, 2010 @ 12:13
    snitram
    0

    Formatting broke :/ I've tried to fix it without any luck - hope it's readable..

  • Magnus Jonsson 33 posts 53 karma points
    Oct 12, 2010 @ 14:19
    Magnus Jonsson
    0

    I think you need to set the defaultMemberTypeAlias(UmbracoMembershipProvider) property in web.config to a MemberType already created in the admin-backend.

    //Magnus

  • snitram 27 posts 48 karma points
    Oct 12, 2010 @ 14:29
    snitram
    0

    I think I already did that, this is currently in my web.config:

        <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear />
            <add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="WebsiteMember" passwordFormat="Hashed" />
            <add name="UsersMembershipProvider" type="umbraco.providers.UsersMembershipProvider" enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false" passwordFormat="Hashed" />
          </providers>
        </membership>

    Do I need to define anything else?

  • snitram 27 posts 48 karma points
    Oct 14, 2010 @ 12:56
    snitram
    0

    I didn't do anything different, but it has started working now. Maybe some caching issue or something, but "member.getProperty('zipcode').Value" works like a charm!

Please Sign in or register to post replies

Write your reply to:

Draft