Albert Casas
  • Posts: 3
  • Joined: 30/09/2016
Hello

It is my firts contact with Yaf and i have any doupts

In my website I need to have a forum, for this reason I need to registers users. I have tried to registrer a new user but I can't

I have use the functon YAF.Classes.Data.LegacyDb.user_save, but with function the db created a new register in the table yaf_User but not i prov_Membershiop (and I don't have sent the password )

Also I tried with YAF.Classes.Data.LegacyDb.user_register but thow error "yaf_user_save procedure need @utctimestamp"

Any idea, how to do it? Is posible do with SSO?

Thanks

Albert
Sponsor
tha_watcha
  • Posts: 4079
  • Joined: 06/03/2010
here is the sample code to add a new user via code...

MembershipCreateStatus status;

var pass = "Password"// Membership.GeneratePassword(32, 16);
var securityQuestion = "Security Question";
var securityAnswer = "Security Answer";
var userName = "UserName";

MembershipUser user = YafContext.Current.Get<MembershipProvider>().CreateUser(
                            userName, pass, email, securityQuestion, securityAnswer, true, null, out status);

// setup inital roles (if any) for this user
RoleMembershipHelper.SetupUserRoles(YafContext.Current.PageBoardID, userName);

// create the user in the YAF DB as well as sync roles...
                        int? userID = RoleMembershipHelper.CreateForumUser(user, YafContext.Current.PageBoardID);

// create empty profile just so they have one
YafUserProfile userProfile = YafUserProfile.GetProfile(userName);

// Set profile properties?!
userProfile.Homepage = "http://www.test.com";

// setup their inital profile information
 userProfile.Save();

if (YafContext.Current.Get<YafBoardSettings>().NotificationOnUserRegisterEmailList.IsSet())
            {
                // send user register notification to the following admin users...
                YafContext.Current.Get<ISendNotification>().SendRegistrationNotificationEmail(user, userID.Value);
            }

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

 LegacyDb.user_save(
                            userId,
                            YafContext.Current.PageBoardID,
                           UserName,
                            null,
                            email,
                            0,
                            null,
                            null,
                            null,
                            true,
                            null,
                            null,
                            null,
                            null,
                            null,
                            null,
                            null,
                            null);

bool autoWatchTopicsEnabled = YafContext.Current.Get<YafBoardSettings>().DefaultNotificationSetting ==
                                                      UserNotificationSetting.TopicsIPostToOrSubscribeTo;

                        // save the settings...
LegacyDb.user_savenotification(
                            userId,
                            true,
                            autoWatchTopicsEnabled,
                            YafContext.Current.Get<YafBoardSettings>().DefaultNotificationSetting,
                            YafContext.Current.Get<YafBoardSettings>().DefaultSendDigestEmail);

UserPostedImage
Users browsing this topic
    Forum Jump  
    • You cannot post new topics in this forum.
    • You cannot reply to topics in this forum.
    • You cannot delete your posts in this forum.
    • You cannot edit your posts in this forum.
    • You cannot create polls in this forum.
    • You cannot vote in polls in this forum.

    About Us

    The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

    Powered by Resharper Donate with PayPal button

    Project Twitter Updates

    Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved