forums plugin missing line of code, I think

By wizzle - July 17, 2017

I just downloaded and configured the simple forums plugin within the past week.  It went live today.  I noticed that I was not getting emails when new topics were created in the categories that I am subscribed to (but I was getting emails for individual threads I was subscribed to).

Digging into the files, I found the following code on /forum/forum-posts-reply.php 

//Send thread followers emails letting them know the thread has been updated.
      sforum_sendFollowersPostNotifications($post, $topic, $forum);

Which is the code that was sending me emails properly when someone replied to a thread.

I looked for something similar in /forum/forum-topics-create.php that would generate an email when a NEW topic was created but I couldn't find it anywhere.  After looking at the function, it seemed to me that the same function is used to send both emails (new topics and replies). So I just copied the code into the forum-topics-create.php file and tested it.  It seemed to work fine!  

I just re-downloaded the simple forum plugin and checked it from a fresh download ... the code is missing from forum-topics-create.php

So my question is this...

Was I right to insert that code so that email will get sent when someone subscribes to a forum ... or is there a different code that does that and I am just not seeing it.  My fix seemed to work but I'm nervous it wasn't the right thing to do.  Is the sforum_sendFollowersPostNotifications functions intended to send both types of subscriber emails or is there a different function I should be using?

thanks.

Greg Williams

By Dave - July 22, 2017

Great find, Wizzle.

That line was missing and it sounds like you added it back in the right place.  

I've released an update with that fix and PHP 7 support.

Thanks for letting us know, much appreciated!

Dave Edis - Senior Developer
interactivetools.com

By wizzle - July 25, 2017

Thanks Dave.

I asked in another thread about a similar issue but it has not received any replies...

Basically I can't figure out how the "subscribe to category" feature works for simple forum.  Is it

If an account is subscribed to an entire category, do they...

A. get emails for all new threads within the category AND for all replies to threads in the category

OR

B. get emails ONLY when a new thread is created (but not the replies to an existing thread).

I assumed it was going to be option B, but based on my user feedback I think it is currently functioning as option A.  

How could I modify the line on  /forum/forum-posts-reply.php (the code that was missing) so that replies to a topic only send emails to people specifically subscribed to that topic, but not to people that are just generally subscribed to the entire category.

I am hoping to achieve option B above.

Greg Williams

By Dave - July 28, 2017

Hi Wizzle, 

It works as you describe in option A:

>A. get emails for all new threads within the category AND for all replies to threads in the category

How could I modify the line on  /forum/forum-posts-reply.php (the code that was missing) so that replies to a topic only send emails to people specifically subscribed to that topic, but not to people that are just generally subscribed to the entire category.

Hmm, there's no easy way to do that.  What you'd probably need to do was modify sforum_sendFollowersPostNotifications() to check how many posts were in a topic ( $topic['posts'] ) and then update sforum_db_getFollowerEmails() to only return forum subscriber emails if the topic only had 1 post.  

It would take a bit of custom programming and experimentation.

Dave Edis - Senior Developer
interactivetools.com

By Dave - August 8, 2017

Hi wizzle, 

Sounds good.  You're getting into some pretty advanced code here.  If at any point you want us to do some consulting to get this working for you just email me direct at dave@interactivetools.com.  Beyond that, you can split the query in sforum_db_getFollowerEmails()  into two queries, and debug it by calling sforum_db_getFollowerEmails() directly from a test script.  Or create a copy of the function sforum_db_getFollowerEmails2().

Let me know how it goes!

Dave Edis - Senior Developer
interactivetools.com

By wizzle - August 17, 2017

Thanks Dave. I'm a novice so this will take some digging on my part.

I did just notice that the auto-generated emails say 

If you don't want to receive updates on this forum topic, please unsubscribe.

So what if I unsubscribe from the forum topic, but I'm still subscribed to the overall forum Category?  Does this link prevent me from getting email notices for replies to that specific topic even if I am subscribed to the entire Forum Category, or does the category subscription override the individual topics?

Greg Williams

By Dave - September 6, 2017

Hi Wizzle, 

Just wanted to follow up and see if you made any progress with this?  I believe the category subscription overrides.  If you want some minor enhancements to the plugin let me know what they are and I can take a look.

Dave Edis - Senior Developer
interactivetools.com