#1
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?
Topic Starter
  • benicillin
  • Rank: YAF Forumling
  • Reputation:
    Neutral
    51.8%
  • Joined: 28/11/2014
  • Posts: 3
  • Thanks: 1 times
#2
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?)



No, but you can retrieve the userid via the provideruserkey

 var userId = UserMembershipHelper.GetUserIDFromProviderUserKey(PROVIDERKEY);


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?



you need all values which you can get from the boardsettings

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

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

UserPostedImage
  • tha_watcha
  • Rank: YAF.NET Project Lead
  • Reputation:
    Exalted
    100%
  • Medals:
    Medal of Honor: Portal Puzzle Master: Portal Puzzle Master for DNNMedal of Honor Key: Given to pillars of the community who are key players in the YAF community and project.DNN Master: DNN Module ManBug Killer Medal of Honor: Medal for being a kick-ass bug killer!Medal of Honor for the Support King: Support King! Amazing asset to the YAF.NET Community.
  • Joined: 06/03/2010
  • Posts: 4,016
  •  Germany
  • Thanks: 73 times
  • Was thanked: 1211 time(s) in 1036 post(s)
#3
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#:

Dim userId As Integer = UserMembershipHelper.GetUserIDFromProviderUserKey(forumuser.ProviderUserKey)
YAF.Classes.Data.LegacyDb.user_savenotification(forumUserID, True, True, YAF.Types.Constants.UserNotificationSetting.TopicsIPostToOrSubscribeTo, False)


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.
Topic Starter
  • benicillin
  • Rank: YAF Forumling
  • Reputation:
    Neutral
    51.8%
  • Joined: 28/11/2014
  • Posts: 3
  • Thanks: 1 times
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