Search code examples
dotnetnukemembership-provideruser-registration

How do I create a user registration Page in DotNetNuke 4.9.2


I am looking for a way to create my own user registration page in DotNetNuke. I do not want to replace the default one, I just want to put dnn registration in a moduule I am building. Any insight on how to go about this would be great, I would like to use the current membership provider included with DotNetNuke.


Solution

  • Everything you need to know is here, hope this helps someone else:

    http://www.engagesoftware.com/Blog/EntryId/75/Membership-Provider-Video-Part-I.aspx

    OK I want to share my code with everyone as this was a pain to figure out, but this will give an idea of what to do:

    using DotNetNuke;
    using DotNetNuke.Common;
    using DotNetNuke.Common.Utilities;
    using DotNetNuke.Entities.Users;
    using DotNetNuke.Entities.Modules;
    using DotNetNuke.Entities.Modules.Actions;
    using DotNetNuke.Security;
    using DotNetNuke.Services.Exceptions;
    using DotNetNuke.Services.Localization;
    using DotNetNuke.Security.Membership;
    
    
    
    
    namespace DotNetNuke.Modules.Promotions
    {
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The ViewPromotions class displays the content
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// </history>
        /// -----------------------------------------------------------------------------
        partial class View : PortalModuleBase, IActionable
        {
     public void btnRegister_Click(object sender, EventArgs e)
            {
                try
                {
    
                    UserCreateStatus userstatus = UserCreateStatus.AddUser;
                    UserInfo NewUser = new UserInfo();
    
                    NewUser.FirstName = txtFirstname.Text;
                    NewUser.LastName = txtLastName.Text;
                    NewUser.Username = txtUserName.Text;
                    NewUser.DisplayName = txtUserName.Text;
                    NewUser.Profile.City = txtCity.Text;
                    NewUser.Profile.Country = "United States";
                    NewUser.Email = txtEmail.Text;
                    NewUser.Username = txtUserName.Text;
                    NewUser.Membership.Password = txtPassword.Text;
                    if (PortalSettings.UserRegistration != Convert.ToInt32(DotNetNuke.Common.Globals.PortalRegistrationType.PublicRegistration))
                    {
                        NewUser.Membership.Approved = true;
                    }
                    {
                        NewUser.Membership.Approved = false;
                    }
    
                    UserCreateStatus userstatsus = UserController.CreateUser(ref NewUser);
                }
                catch (Exception ex)
                {
                    Console.Write(ex);
                }
            }