Welcome Guest! To enable all features please
Login or Register.
I normally code in C#
I have a website that has it's own user database, not using the ASP.NET Membership provider. In fact, this website doesn't have any log in at all, but user details are stored when people register for the organization.
So, I have a database with email addresses and names and I want to add these users to the YAF user database and assign a password for them.
My thought is that my program would run every day and automatically add any users who have registered on the original site and send them an email with their password.
I have added the connectionStrings and system.web sections to my app.config exactly as they are in the YAF configs.
I have also added the YAF.dll to my references.
I can run YAF.Providers.Membership.DB.Current.CreateUser("YetAnotherForum", "TestUser", FormsAuthentication.HashPasswordForStoringInConfigFile("TestPassword!", "SHA1"), "", 0, "firstname.lastname@example.org", "", "", true, YAF.Providers.Profile.DB.Current.GetProviderUserKey("YetAnotherForum", "TestUser"));
I get no errrors, but the user does not appear in the YAF database or Admin panel.
If you could offer any help on what I am missing or doing wrong I would appreciate it.
Thanks in advance!
Here is the full code to register a user and send the user an email
var pass = Membership.GeneratePassword(32, 16);
var securityAnswer = Membership.GeneratePassword(64, 30);
var securityQuestion = "Answer is a generated Pass";
var user = YafContext.Current.Get<MembershipProvider>().CreateUser(
this.Get<MembershipProvider>().RequiresQuestionAndAnswer ? securityQuestion : null,
this.Get<MembershipProvider>().RequiresQuestionAndAnswer ? securityAnswer : null,
// setup inital roles (if any) for this user
// 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");
// send user register notification to the new users
user, pass, securityAnswer, "NOTIFICATION_ON_REGISTER");
var autoWatchTopicsEnabled = this.Get<YafBoardSettings>().DefaultNotificationSetting
// save the settings...
- 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.