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.04.9.1 Adding "core" fields to user table4.9.1 Adding "core" fields to user table
Previous
 
Next
New Post
2/12/2009 9:30 AM
 

Ronald wrote

the fields are required in the registration process, and i added them to profile properties but dont know how to insert the registration textbox values into them.

the sample you sent me only lead me to something that looks the opposite to me
ParticipationsController.InstitutionUserInsert(inst.ID, info.UserID);

i dont really see where it takes the custom field information and writes it to the DNN userprofile.

 

My bad.  I just searched through my old posts because I know I've posted this before by my post history only goes back one year (hard-coded limitation in the Forum I wonder?).  Anyway... here is a sample pulled right out of production code (and formatted a little to fit).  Hopefully this will get you there.

 
DotNetNuke.Entities.Users.UserInfo info = new DotNetNuke.Entities.Users.UserInfo();
info.Profile.InitialiseProfile(portalId);
info.PortalID = 0;
info.Profile.PreferredLocale = "en-US";

info.Username = userName;
// set membership
info.Membership.Email = rec.Email;
info.Membership.Password = UserController.GeneratePassword(9);
info.Membership.Username = userName;
info.Email = rec.Email;
info.FirstName = rec.FirstName;
info.LastName = rec.LastName;
info.DisplayName = rec.DisplayNameFirstLast;

// set profile
info.Profile.FirstName = rec.FirstName;
info.Profile.LastName = rec.LastName;
info.Profile.SetProfileProperty("Date_of_Birth", rec.DateOfBirth.ToShortDateString());
info.Profile.SetProfileProperty("Seniority_Date", rec.HireDate.ToShortDateString());
info.Profile.SetProfileProperty("Cell", rec.Cell);
info.Profile.SetProfileProperty("Fax", rec.Fax);
info.Profile.SetProfileProperty("Work_Phone", rec.WorkPhone);
info.Profile.SetProfileProperty("Other_Phone", rec.OtherPhone);

DotNetNuke.Security.Membership.UserCreateStatus crStat = UserController.CreateUser(ref info);
if (crStat == DotNetNuke.Security.Membership.UserCreateStatus.Success)
{
	result.ImportStatus = ImportStatus.UserCreated;
	messages.Add("Employee: " + info.DisplayName + " created.");
}
else if (crStat == DotNetNuke.Security.Membership.UserCreateStatus.DuplicateEmail || 
crStat == DotNetNuke.Security.Membership.UserCreateStatus.DuplicateUserName)
{
	result.ImportStatus = ImportStatus.Error;
	messages.Add("Employee: " + info.DisplayName + " not created, has duplicate email already in system.");
}
else if (crStat == DotNetNuke.Security.Membership.UserCreateStatus.UsernameAlreadyExists)
{
	result.ImportStatus = ImportStatus.Error;
	messages.Add("Employee: " + info.DisplayName + " not created, username already exists for other employee.");
}
else
{
	result.ImportStatus = ImportStatus.Error;
	messages.Add("Employee: " + info.DisplayName + " not created, other error.");
}

 


-- Jon Seeley
DotNetNuke Modules
Custom DotNetNuke and .NET Development
http://www.seeleyware.com
 
New Post
2/12/2009 10:38 AM
 

im sorry, but now im even more confused..

i have
info.Profile.SetProfileProperty("Installation_ID", txtInstallID.Text);

this works. but when i call
DotNetNuke.Security.Membership.UserCreateStatus crStat = UserController.CreateUser(ref info);

nothing happens, no user gets added or whatever... ill paste the code here

//Retreive firstname, lastname and compile it into a no spaces user/displayname
            string fName = Replace_Spaces(txtFirstName.Text);
            string lName = Replace_Spaces(txtLastName.Text);
            string uName = fName + "." + lName;
            if (uName.Length > 50) { uName.Remove(50); }

            //DotNetNuke.Security.Membership.UserCreateStatus crStat;

            //Add user first
            DotNetNuke.Entities.Users.UserInfo info = new DotNetNuke.Entities.Users.UserInfo();
            info.Profile.InitialiseProfile(this.PortalId);
            info.DisplayName = uName;
            info.Username = uName;
            info.Email = txtEmail.Text;
            info.FirstName = txtFirstName.Text;
            info.LastName = txtLastName.Text;
            //info.Installation_ID = txtInstallID.Text;

            info.Profile.SetProfileProperty("Installation_ID", txtInstallID.Text);
            info.Profile.SetProfileProperty("Company_Name", txtCompanyName.Text);

            DotNetNuke.Security.Membership.UserCreateStatus crStat = UserController.CreateUser(ref info);
            /*if (crStat == DotNetNuke.Security.Membership.UserCreateStatus.Success)
            {
                result.ImportStatus = ImportStatus.UserCreated;
                messages.Add("Employee: " + info.DisplayName + " created.");
            }
            else if (crStat == DotNetNuke.Security.Membership.UserCreateStatus.DuplicateEmail ||
            crStat == DotNetNuke.Security.Membership.UserCreateStatus.DuplicateUserName)
            {
                result.ImportStatus = ImportStatus.Error;
                messages.Add("Employee: " + info.DisplayName + " not created, has duplicate email already in system.");
            }
            else if (crStat == DotNetNuke.Security.Membership.UserCreateStatus.UsernameAlreadyExists)
            {
                result.ImportStatus = ImportStatus.Error;
                messages.Add("Employee: " + info.DisplayName + " not created, username already exists.");
            }
            else
            {
                result.ImportStatus = ImportStatus.Error;
                messages.Add("Employee: " + info.DisplayName + " not created, other error.");
            }*/

I commented out the last big chunk because it was nagging about  Importstatus not defined, as well as result

 
New Post
2/12/2009 1:34 PM
 

Way close.  You were missing setting the portalID for the user and setting the "Membership" fields.  I'd check your database and see if it created them at all but it probably didn't.  You need to check the crStat for what status came back, either an error or success.  Here is a modified copy of what you posted:

//Retreive firstname, lastname and compile it into a no spaces user/displayname
string fName = Replace_Spaces(txtFirstName.Text);
string lName = Replace_Spaces(txtLastName.Text);
string uName = fName + "." + lName;
if (uName.Length > 50) { uName.Remove(50); }

//Add user first
DotNetNuke.Entities.Users.UserInfo info = new DotNetNuke.Entities.Users.UserInfo();
info.Profile.InitialiseProfile(this.PortalId);
info.PortalID = this.PortalId; // JTS added
//info.Profile.PreferredLocale = "en-US"; // JTS added; not required so I commented out
info.DisplayName = uName;
info.Username = uName;
info.Email = txtEmail.Text;
info.FirstName = txtFirstName.Text;
info.LastName = txtLastName.Text;
// JTS added; need to set the membership data as well
info.Membership.Email = txtEmail.Text;
// you can generate length of any size you want, i just added 
// 10 for the heck of it; you'd probably want to prompt them
// for a password though
info.Membership.Password = DotNetNuke.Entities.Users.UserController.GeneratePassword(10);
info.Membership.Username = uName;

info.Profile.FirstName = fName;
info.Profile.LastName = lName;
info.Profile.SetProfileProperty("Installation_ID", txtInstallID.Text);
info.Profile.SetProfileProperty("Company_Name", txtCompanyName.Text);

DotNetNuke.Security.Membership.UserCreateStatus crStat = UserController.CreateUser(ref info);
if (crStat == DotNetNuke.Security.Membership.UserCreateStatus.Success)
{
 // TODO: some logic that shows they successfully created their user
}
// TODO: else, maybe check the other statuses from the 
// enum and display messages appropriately
//else if crStat == DotNetNuke.Security.Membership.UserCreateStatus.DuplicateEmail) { }

-- Jon Seeley
DotNetNuke Modules
Custom DotNetNuke and .NET Development
http://www.seeleyware.com
 
New Post
2/13/2009 3:42 AM
 

sweet, now the registration module works and writes the correct data as well

*edit 3*
i have this part finished, thanks for the help

my apologies for the bother, i really havent got much clues as to how DNN jumps around with all the User data and such. i just had some basic C# books that i finished but thats all knowledge i have...

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.04.9.1 Adding "core" fields to user table4.9.1 Adding "core" fields to user table


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