Copied to clipboard

Flag this post as spam?

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


  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jun 01, 2010 @ 23:33
    Peter Dijksterhuis
    0

    membershipprovider and requiresUniqueEmail="false"

    Hi All,

    I'm working with the default asp.net membershipprovider. Now, by default, that requires that all members registere have all unique email-addresses.

    However, I'd like to override that because I do not need emails to be unique.

    Is there any way I can tell the default controls to skip testing for emailaddress or is there any example code out there that allows the creation of users without checking for existing emails?

    Thanks in advance,

    Peter

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jun 01, 2010 @ 23:38
    Nik Wahlberg
    0

    Hi Peter, here is what I have done in the past that has seemed to work fine. For member registration, hook into the following event:

    protected void CreateUserWizard1_CreatingUser(object sender, EventArgs e)
    {
        Literal errorMsg = (Literal)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ErrorMsg");
        TextBox email = (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName");
        Member m = Member.GetMemberFromEmail(email.Text);
    
        if (m!=null)
        {
            errorMsg.Text = "The email you specified is already taken. Please choose another email.";
            return;
        }
    }

    And, OR, you could alternatively create your own provider and override the method that way. The above keeps your error handling to the code behind without overriding the default Umbraco Membership provider. 

    HTH,
    Nik

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jun 01, 2010 @ 23:42
    Nik Wahlberg
    0

    So, if you were to entend the UmbracoMembershipProvider you'd have something like this:

    public class CustomMembershipProvider : umbraco.providers.members.UmbracoMembershipProvider
    {
        ...
    
        public override string GetUserNameByEmail(string email)
        {
            return base.GetUserNameByEmail(email);
        }
    
        ...
    }

    That should give you some ways to go about it...

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jun 01, 2010 @ 23:52
    Peter Dijksterhuis
    0

    Works like a charm! Thanks!

    Peter

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Jun 02, 2010 @ 00:35
    Nik Wahlberg
    0

    Glad it helped you out! 

    -- Nik

Please Sign in or register to post replies

Write your reply to:

Draft