Support » Plugin: AsynCRONous bbPress Subscriptions » include post author in notifications?

  • Resolved strike3

    (@strike3)


    Hi,
    Is there any way to send new topic notifications to post authors with ABBPS? I found this code in two places in the actual bbpress plugin and commented it out:

    (From /bbpress/includes/common/functions.php – it’s part of bbp_notify_forum_subscribers)

    // Don’t send notifications to the person who made the post
    if ( !empty( $topic_author ) && (int) $user_id === (int) $topic_author)
    {
    continue;
    }

    However, the notifications are still not going to post authors. It looks like ABBPS is actually the plugin sending out our notification emails (the abbps_notify_topic_subscribers function), so I’m wondering if there’s something we can add to that function to get this working?

    Thank you for any advice!

    Matt

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Markus Echterhoff

    (@mechter)

    Hello,

    sure there is a way to do this, although it would seem the post author already knows that they posted a new topic before they even get the notification email, so it’s not clear to me why you’d want to do this.

    Also note that editing the code of plugins directly (as you did by commenting out those lines) is recommended against because when you update the plugin your changes will be overwritten. Better to use hooks.

    Anyway, I’ve looked through the code and it would seem you could try adding the following to your theme’s functions.php file:

    add_filter( 'bbp_forum_subscription_user_ids', function( $user_ids ) {
    	$user_ids[] = bbp_get_forum_last_topic_author_id();
    	return $user_ids;
    }, 10, 1 );
    Thread Starter strike3

    (@strike3)

    Hi Markus,
    Thanks for your help! Yeah, it is a weird request. They moderate all the posts on their forum, so I think they’re wanting people to know when the topic is approved/posted. I couldn’t get the code above to work, but I think I just found the line in ABBPS that was causing this. They’re using version 3.3 of the plugin, and this was line 146 in asynchronous-bbpress-subscriptions.php:

    $user_ids = array_diff( $user_ids, array( bbp_get_topic_author_id( $topic_id ) ) );

    If I comment that out, the authors get the notification. Like you said, though, it’s not ideal to comment things out of the main plugin. I guess if the plugin isn’t getting updates, though, I could just leave it at that. Otherwise, do you know how I could get that to work through functions.php? If I tried to add the author back to the array, I’m not sure which would happen last before the notifications went out (i.e., would the author get removed again by the line above?).

    Thanks again for taking the time to reply on this. Let me know if there’s a way for me to buy you a cup of coffee or something!

    Matt

    Plugin Author Markus Echterhoff

    (@mechter)

    Hey Matt,

    sorry for the delayed response. When I got the notification mail about your post, the message didn’t show up on the forums. I wasn’t sure whether it was delayed or deleted, and then I kind of forgot to check back until today.

    Since the workaround code I posted above doesn’t seem to work for you (I haven’t tested it myself, but it looked like it could maybe work), I’ve added a filter for your use case. I didn’t plan on doing any further development on this plugin, but I’d rather not have you edit files directly just in case I do have to patch something important in the future. Plus, adding a filter is a quick job. Please upgrade the plugin to version 3.7 and add the following to your theme’s functions.php:

    add_filter( 'bbp_forum_subscription_notify_author', '__return_true' );

    No donation necessary, but thanks for offering. I’m glad I could help. If you insist, you can find a donation link in the header of the included readme.txt file or at the bottom of the right sidebar of this plugin’s page here on wordpress.org.

    Thread Starter strike3

    (@strike3)

    Great, thanks so much!

    Matt

    Plugin Author Markus Echterhoff

    (@mechter)

    And thank you! 🙂

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘include post author in notifications?’ is closed to new replies.