YAFLogo

Posted by: benicillin - Saturday, 29 November 2014 00:22:02
I am creating users myself using the membership provider CreateUser function I can call YAF.Classes.Data.LegacyDb.user_savenotification but i only want to change the notificationType value, and i need to be able to supply the userID. the function expects parameters userID, pmNotification, autoWatchTopics, notificationType, and dailyDigest. 1) How do I find the userID? (is this the ProviderUserKey stored in the object that is created by the CreateUser function?) 2) Can i set just the notificationType object, or do i need to also provide the pmNotiication object, autoWatchTopics object, and dailyDigest object? if so, how do i pull the values for those objects for the specified user?

Posted by: tha_watcha - Saturday, 29 November 2014 14:11:17
Simply check the standard yaf process in the register.ascx.cs page on how to create a user [quote]1) How do I find the userID? (is this the ProviderUserKey stored in the object that is created by the CreateUser function?)[/quote] No, but you can retrieve the userid via the provideruserkey [code=csharp] var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(PROVIDERKEY);[/code] [quote]2) Can i set just the notificationType object, or do i need to also provide the pmNotiication object, autoWatchTopics object, and dailyDigest object? if so, how do i pull the values for those objects for the specified user?[/quote] you need all values which you can get from the boardsettings [code=csharp]bool autoWatchTopicsEnabled = this.Get().DefaultNotificationSetting == UserNotificationSetting.TopicsIPostToOrSubscribeTo; // save the settings... LegacyDb.user_savenotification( userId, true, autoWatchTopicsEnabled, this.Get().DefaultNotificationSetting, this.Get().DefaultSendDigestEmail);[/code]

Posted by: benicillin - Saturday, 29 November 2014 17:44:51
Thanks for the quick reply. Great project. Just for the record, those values are stored in the yaf_User table under the field name autoWatchTopics (boolean) and NotificationType (integer) i used the following code to set a NEW user notification settings by default to receive PM notifications by email, auto watch topics, receive notifications for topics i post or subscribe to, and NOT receive the digest. code is VB not C#: [code=csharp]Dim userId As Integer = UserMembershipHelper.GetUserIDFromProviderUserKey(forumuser.ProviderUserKey) YAF.Classes.Data.LegacyDb.user_savenotification(forumUserID, True, True, YAF.Types.Constants.UserNotificationSetting.TopicsIPostToOrSubscribeTo, False)[/code] where forumUser is a MembershipUser object created by the membership provider's "CreateUser" function. i added this to my createYAFUser function just after the blank profile is created - i worked off the YAFNET sample project.