Copied to clipboard

Flag this post as spam?

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


  • Dmitrij Jazel 86 posts 179 karma points
    Mar 03, 2013 @ 21:04
    Dmitrij Jazel
    0

    How to create new Member Umbraco 6.0.1

    Hello everyone,

    I am trying to use Umbaco 6.0.1 rescent releas since there you could finally edit profile and .save() the changes.

    So far everything works fine...

    Except when I am trying to create new Member in C#.

    I am currently using this code here to create it, it seams like it goes through (no exceptions or anything) but the member is not created.

    //create new member
    var newmember = System.Web.Security.Membership.CreateUser(userName, password, email);
    var profile = ProfileBase.Create(userName);
    profile["name"] = name;
    profile["telephone"] = telephone;
    profile["age"] = age;
    profile.Save();           

    Note I do have a Member type in umbraco - type is called: "BasicUser"

    Profile works when I am edditing Existing members or if they are added through administration.

    I can save and extract information from there.

     

    So my problem here is when I run this code, new Member is not created (I cannot see him among members in administration > members).

     

    Any suggestions?

    //Dmitrij

  • Charles Afford 1163 posts 1709 karma points
    Mar 03, 2013 @ 22:04
    Charles Afford
    0

    Hey Demitrij, pretty sure you have to call provider.EncodePassword(string password) first, i dont think the password is encoded when you execute CreateUser() thus it does not get saved to the database.  Hope this helps :)

  • Dmitrij Jazel 86 posts 179 karma points
    Mar 04, 2013 @ 21:09
    Dmitrij Jazel
    0

    Hej Charlie :)

    Allright, well this might help, but in my example I am not referencing "provider", and I can see in your example you are referencing it via "provider." and than calling EncodePassword() method on it... could you maybe provide a snippet for that? :)

    //Dmitrij

  • Charles Afford 1163 posts 1709 karma points
    Mar 04, 2013 @ 21:19
    Charles Afford
    0

    Hi, sorry igone that above :).  You simply need to use

    Try using this to begin with and see it that works.  I can get this to work in Umbraco 4.11.1

    Membership.CreateUser(userName, password, email);
    Charlie :)
  • Charles Afford 1163 posts 1709 karma points
    Mar 04, 2013 @ 21:24
    Charles Afford
    0
    var newmember =System.Web.Security.Membership.CreateUser(userName, password, email);
    Pretty sure this is the problem. Just use Membership member = new Membership.CreateUser(userName, password, email);
    ....
    ....
    Hope this helps :)
  • Dmitrij Jazel 86 posts 179 karma points
    Mar 04, 2013 @ 22:52
    Dmitrij Jazel
    0

    Yea, well it gives some extra space to think :)

    But aren't you supposed to use the membership class that I made (class is called "myMember")?

    and in your example here you are suggesting to use this:

    var newmember = System.Web.Security.Membership.CreateUser(userName, password, email);

    but that is same as I am using... and it might be me, but I can't figure out where should I use the "provider", or how should I understand this one :)

    I am sorry for this confusion, but I hope we can figure this one somehow :)))

    Do we have some more suggestions? :(

     

    //Dmitrij

     

     

  • Charles Afford 1163 posts 1709 karma points
    Mar 06, 2013 @ 22:13
    Charles Afford
    0

    sorry :) yea that was a bit misleading, what you need to do is on the CreateUser method there is a parameter which i think is an out parameter for success.  If you put a string in this paramater and then have a look at it when debugging it will tell you why the user is not being created.  Charlie :)

Please Sign in or register to post replies

Write your reply to:

Draft