YAFLogo

rai
  • rai
  • 100% (Exalted)
  • YAF Commander Topic Starter
12 years ago
Hi,

I am doing some custom integration of the forum and my customers. I have managed to create a user but it does not seem to autocreate a row in yaf_UserGroup causing logon to fail.

Is there a specific existing method for this or should just insert a row after creating the user?

Here is my code for creating the user:

System.Web.Security.MembershipCreateStatus status;
                    userInfo = System.Web.Security.Membership.CreateUser(txtLogin.Text, txtPassword.Text, c.YafUserID, txtQ.Text, txtA.Text, true,out status);
                    if (status == System.Web.Security.MembershipCreateStatus.Success)
                    {
                        //userInfo.IsApproved = true;
                        System.Web.Security.Membership.UpdateUser(userInfo);
                        var p = Profile.GetProfile(userInfo.UserName);
                        p.RealName = string.Format("{0} {1}", txtFirstName.Text, txtLastName.Text);
                        p.Save();
                        db.ExecuteCommand("Update Contacts set YafUserID={0}, InviteCode=null,InviteSentOn=null Where YafUserID={1}", userInfo.UserName, c.YafUserID);
                        // insert into yaf_UserGroup
                        System.Web.Security.FormsAuthentication.SetAuthCookie(userInfo.UserName, true);

Thanks!

Sponsor
tha_watcha
  • tha_watcha
  • 100% (Exalted)
  • YAF.NET Project Lead 🤴 YAF Version: 4.0.0 rc 2
12 years ago
take a look at the yaf register page and you see how the user profile is setup...

// setup/save the profile
        YafUserProfile userProfile = YafUserProfile.GetProfile(this.CreateUserWizard1.UserName);

        userProfile.Location = locationTextBox.Text.Trim();
        userProfile.Homepage = homepageTextBox.Text.Trim();

        userProfile.Save();

        // save the time zone...
        int userId = UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey);

        LegacyDb.user_save(
            userId, 
            this.PageContext.PageBoardID, 
            null, 
            null, 
            null, 
            timeZones.SelectedValue.ToType<int>(), 
            null, 
            null, 
            null,
            null,
            null,
            null, 
            null, 
            null, 
            null, 
            dstUser.Checked, 
            null, 
            null);