Recently we've received the same question from several customers with regard to automatically subscribing new users to all forums via email within InstantForum.NET. This would ensure all members are sent an email each time a post is made within any forum they have access to.
We don't do this by default as it's generally best practice to allow your users to opt-in to email notifications however we understand some customers may be running InstantForum.Net within a controlled internal intranet We will be adding options in a future InstantForum.NET release to allow you to automatically subscribe your users to specific forums however whilst we work on getting this right I wanted to share some simple code which may help in the meantime.
I would only suggest using this code if you know your users won't mind being automatically subscribed to all forums by email. Generally for public facing web sites this is not a good idea as you may quickly annoy community members with unsolicited emails. Please use your judgement before deciding to apply this code.
To automatically subscribe new members you'll need to modify the registration code to call an additional method that will loop through forums and add a subscription automatically. To get started open your InstantForum.NET installation within Visual Studio.NET and locate the register page as shown below…

Open this class. You should see…

Adding Imports Statement
You'll need to add the an imports / using statement to InstantASP.InstantForum as shown below…

Add our New Method
One you've added the imports / using statement copy the code below and paste this above the QueueConfirmationEmails nethod as shown below….
Private Sub AutoForumSubscription(ByVal intUserID As Int32)
' create forum object, pass current user id to ensure role based security is applied
Dim Forums As New Business.Forums(MyBase.CurrentContext.CurrentUser.UserID)
' populate local forum collection
Dim fc As Collections.ForumCollection = Forums.SelectForums
' check we have a forum collection
If Not fc Is Nothing Then
' loop through forums
For index As Int32 = 0 To fc.Count - 1
' get forum
Dim f As Components.Forum = fc.Item(index)
' add forum Subscription
Business.Subscriptions.Forums.InsertSubscription( _
intUserID, f.ForumID, Common.Enumerations.EnumSubscriptionType.Instant)
Next
End If
End Sub
Calling the New Method
You will now need to call the new "AutoForumSubscription" method we have added when adding the user. Todo this locate the code below iwthin Register.vb.
User = New InstantASP.InstantForum.Components.User(intUserID)
User.Authenticate(e.RememberMe)
' quque confirmation email
QueueConfirmationEmails(User)
Add a call to the new "AutoForumSubscription" method we created as shown below…
User = New InstantASP.InstantForum.Components.User(intUserID)
User.Authenticate(e.RememberMe)
' quque confirmation email
QueueConfirmationEmails(User)
' auto subscribe to all forums
AutoForumSubscription(User.UserID)
When new members register on your site now they will automatically be subscribed to all forums and will receive an email notification anytime a new post is made within any forum the user has access to.
Any questions as always please don't hesitate to contact us.
On a scale of 1-5, please rate the helpfulness of this blog entry
Optionally provide your comments to help us improve this blog entry...
Thank you for your feedback!