Copied to clipboard

Flag this post as spam?

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


  • Delete me 45 posts 66 karma points
    Oct 12, 2009 @ 13:51
    Delete me
    0

    Save member name

    Hi there

    I have this code for creating members:

    <script runat="server">
    protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
    {
    Roles.AddUserToRole(CreateUserWizard1.UserName, "Group");
    }
    </script>
    <asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
    O
    nCreatedUser="CreateUserWizard1_CreatedUser"
    A
    utoGeneratePassword="True" >
    </asp:CreateUserWizard>

     

    Now I want the member to be able to input their "real name", and save it in the "Name" field which the Umbracho Member section already have.

    The "real name" field appears to be m.Text:
    http://our.umbraco.org/forum/developers/api-questions/2930-Getting-member-name

    How can this be done?

    Thanks in advance!
    /Mathias

    PS: Sorry for all my q's, but I'm a total newbee in this..

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 12, 2009 @ 15:15
    Dirk De Grave
    0

    Mathias,

    Have a look at this wiki article which explains the .net membership features. Basically, you'll have to retrieve the member (you'll need a cast from MembershipUser) and set the text property as you mention in your post.

    var member = Membership.GetUser(username); 

    Hope this helps.

    Regards,

    /Dirk

  • Delete me 45 posts 66 karma points
    Oct 12, 2009 @ 21:02
    Delete me
    0

    Thank you!

    Unfortunately I'm stuck in saving the fullname:

    string sName = "Test Test";
    //MembershipUser memUser = Membership.GetUser(CreateUserWizard1.UserName); 
    var memUser = Membership.GetUser(CreateUserWizard1.UserName); 
    memUser.Text = sName; 
    Membership.UpdateUser(memUser);

    It doesnt seem to recon the "Text" property..

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 13, 2009 @ 09:05
    Dirk De Grave
    0

    Mathias,

    Because Membership.GetUser() returns a MembershipUser object rather than a 'Member' object. You'll need to cast to 'Member' to be able to use the .Text property (Just as said in first reply)

     

    Cheers,

    /Dirk

  • Delete me 45 posts 66 karma points
    Oct 13, 2009 @ 12:22
    Delete me
    0

    Would it be possible for you to make a code example? I can not work out how to use the Member object. I'm not sure if it has relevance, but I'm using the code as script directly in the template.

    Thanks again, and sorry for my ignorance!

    /Mathias

  • Delete me 45 posts 66 karma points
    Oct 15, 2009 @ 00:01
    Delete me
    0

    I found out at last! 

    Just had to add 

    <%@ Import Namespace="umbraco.cms.businesslogic.member" %> 

    in the script to use the Member object.

  • Bo Kingo Damgaard 157 posts 456 karma points
    Sep 20, 2010 @ 15:49
    Bo Kingo Damgaard
    0

    Sorry for posting in this old thread, but I've can't cast the MembershipUser to a Member user. I get the error "Cannot convert type 'System.Web.Security.MembershipUser' to 'umbraco.cms.businesslogic.member.Member'"

    /Bo

Please Sign in or register to post replies

Write your reply to:

Draft