Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Customize Register pageCustomize Register page
Previous
 
Next
New Post
9/5/2008 3:45 PM
 

Hi All,

I need to add two required fields when a user registers to our portals. I want to modify the core code. What file holds UserName, FirstName, DisplayName & EmailAddress? I understand that modifying the core code is not recommended but if I can duplicate the files and code I'll do that and create a custom module.

Thanks,

Edward

 
New Post
9/5/2008 5:56 PM
 

You can very easily add two required fields without coding.  Simply do the following:

1. Login as the Administrator
2. Go to User Accounts
3. Click on Manage Profile Properties
4. Add them ... make them required and visible and they will show up during registration.  You can even order and group them.  If you already have users they will be required to update their profile on next login.

What I did on one project was actually just create a Module that effectively creates a user as an end result.  I placed that on a page and configured DNN to not allow Registration.  Then I created a link for non-authenticated users which directs registration to that page.  Here's some VB.NET code I use to create a user:

 ' Insert

                Try

                    Dim oUserInfo As New UserInfo
                    oUserInfo.Profile.InitialiseProfile(Me.PortalId)
                    oUserInfo.PortalID = Me.PortalId
                    oUserInfo.IsSuperUser = False
                    oUserInfo.Membership.Approved = True
                    oUserInfo.Username = txtUsername.Text.Trim
                    oUserInfo.FirstName = txtFirstName.Text.Trim
                    oUserInfo.LastName = txtLastName.Text.Trim
                    oUserInfo.DisplayName = txtDisplayName.Text.Trim
                    oUserInfo.Email = txtEmailAddress.Text.Trim
                    oUserInfo.Profile.SetProfileProperty("Some_ProfileProperty", txtSomeProfileProperty.Text.Trim)
                    oUserInfo.Profile.TimeZone = dnnTimeZone.Value
                    oUserInfo.Profile.PreferredLocale = dnnPreferredLocale.Value

                    ' Role

                    Dim oRoleController As New DotNetNuke.Security.Roles.RoleController

                    If rblRole.Items.FindByText("Some Role").Selected Then

                        oRoleController.AddUserRole(Me.PortalId, oUserInfo.UserID, oRoleController.GetRoleByName(Me.PortalId, "Some Role").RoleID, Nothing)

                    ElseIf rblRole.Items.FindByText("Some Other Role").Selected Then

                        oRoleController.AddUserRole(Me.PortalId, oUserInfo.UserID, oRoleController.GetRoleByName(Me.PortalId, "Some Other Role").RoleID, Nothing)

                    End If

                    ' Password

                    oUserInfo.Membership.Password = txtPassword.Text.Trim

                    ' Save

                    Dim oUserCreateStatus As Security.Membership.UserCreateStatus = DotNetNuke.Entities.Users.UserController.CreateUser(oUserInfo)

                    If Not oUserCreateStatus = Security.Membership.UserCreateStatus.Success Then

                        Select Case oUserCreateStatus

                            Case Security.Membership.UserCreateStatus.DuplicateUserName

                                ' Throw

                                Throw New Exception("Username is already taken.")

                            Case Security.Membership.UserCreateStatus.InvalidEmail

                                ' Throw

                                Throw New Exception("Email is invalid.")

                            Case Security.Membership.UserCreateStatus.InvalidPassword

                                ' Throw

                                Throw New Exception("Password is invalid.")

                            Case Security.Membership.UserCreateStatus.InvalidUserName

                                ' Throw

                                Throw New Exception("Username is invalid.")

                            Case Security.Membership.UserCreateStatus.UserAlreadyRegistered

                                ' Throw

                                Throw New Exception("This User is already registered.")

                            Case Security.Membership.UserCreateStatus.UsernameAlreadyExists

                                ' Throw

                                Throw New Exception("Username already exists.")

                            Case Else

                                Throw New Exception("Unable to Add User due to an unknown error.")

                        End Select

                    End If
 

Another solution would be to buy something like this:

http://www.snowcovered.com/Snowcovered2/Default.aspx?tabid=242&PackageID=10957

Lastly, you could customize what's there but the Registration process is buried in multiple ASCXs and just plain difficult to augment.  I even had a hard time doing something as simple as adding a cookie to remember Username to login and it took quite some time to get it right with the complexity of the User account setup components. 

 
New Post
9/8/2008 9:33 AM
 

Keith,

Thank you for your reply. I created the fields and made them required and visible but DNN doesn't show the fields during registration but I comes up when I logout then log back in again. Am I missing a setting?

 

Thanks,

Edward

 
New Post
9/9/2008 8:45 AM
 

1. Login as Administrator
2. Go to Admin -> User Accounts
3. Click on User Settings
4. Select Require a valid Profile for Registration
5. Select Require a valid Profile for Login
6. Click Update

You should be golden.  Sorry I forgot about this step.

 
New Post
9/10/2008 9:21 AM
 

Keith,

Thank you that did it. My next hurdle is adding a link. I need to add a link to our privacy policy so that when a user is registering he/she can click the privacy policy. I was looking at adding the link to profile fields but there isn't a datatype for hyperlink. Do you have any recommendations in implementing a section for a user to read a company's privacy policy? I will be looking into the module that you recommended earlier.

Thank you for your help,

Edward

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Customize Register pageCustomize Register page


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out