Havent been able to figure how to add an DNN user, I went thru the forum and seen some VB code, but the same doesnt seem to work for me after I converted it to C#. If anyone has encoutered the same problem I would appreciate any help.
the following code:
UserInfo
newUserInfo = new DotNetNuke.Entities.Users.UserInfo();
newUserInfo.Profile.InitialiseProfile(
this.PortalId);
newUserInfo.PortalID = PortalId;
newUserInfo.Email = txtEmail.Text;
newUserInfo.Username = txtEmail.Text;
newUserInfo.FirstName = FirstName;
newUserInfo.LastName = LastName;
newUserInfo.DisplayName = FirstName + LastName;
newUserInfo.Membership.Approved =
true;
newUserInfo.Membership.Password = txtPassword.Text;
newUserInfo.Profile.FirstName = FirstName;
newUserInfo.Profile.LastName = LastName;
UserCreateStatus
userCreateStatus = new UserCreateStatus();
userCreateStatus =
UserController.CreateUser(newUserInfo);
This will generate an error message that says:
DotNetNuke.Services.Exceptions.ModuleLoadException: c:\CMEWeb\DesktopModules\Learner\Register.ascx.cs(399): error CS1502: The best overloaded method match for 'DotNetNuke.Entities.Users.UserController.CreateUser(ref DotNetNuke.Entities.Users.UserInfo)' has some invalid arguments ---> System.Web.HttpCompileException: c:\CMEWeb\DesktopModules\Learner\Register.ascx.cs(399): error CS1502: The best overloaded method match for 'DotNetNuke.Entities.Users.UserController.CreateUser(ref DotNetNuke.Entities.Users.UserInfo)' has some invalid arguments at System.Web.Compilation.AssemblyBuilder.Compile() at System.Web.Compilation.BuildProvidersCompiler.PerformBuild() at System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) at System.Web.UI.TemplateControl.LoadControl(VirtualPath virtualPath) at System.Web.UI.TemplateControl.LoadControl(String virtualPath) at DotNetNuke.UI.Skins.Skin.InjectModule(Control objPane, ModuleInfo objModule, PortalSettings PortalSettings)
Alternatively I tried what I did on DNN 3.3:
UserController
objUsers = new UserController();
int
UserId = objUsers.AddUser(newUserInfo);
using AddUser instead of CreateUser, which gives me back the UserID on DNN3, but on DNN 4.3, I get a '-1' back everytime and can never successfully add the user
Any help appreicated
Thanks