Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Trouble with $topic_id = bbp_get_reply_topic_id( $reply_id );

@antipole

Participant

It turns out to be horribly messy in my original approach. I had to poke around to pick up stuff in different places depending on whether it was invoked from the font or backend. As an example:

$forum_id =  bbp_get_topic_forum_id($topic_id);  // This often does not work here
		if (!$forum_id){	// need to find it elsewhere, which is different for front and backend submissions
			$forum_id = $_POST['bbp_forum_id'] ? $_POST['bbp_forum_id'] : $_POST['parent_id'];
			}

Note for frontend it is to be found in $_POST[‘bbp_forum_id’] and for backend submissions $_POST[‘parent_id’]

In the end I adopted Robin’s suggestion for hooking onto bbp_topic_attributes_metabox_save for backend and onto bap_new_topic and bap_new_reply for frontend.

So I now have a much simpler plugin which is sending notifications when topics or replies are actually published (even after moderation) and which works with publication from front or back ends and for moderation approval in front or backends.
Subscription choices are lost during moderation and not available in the backend. So I force-subscribe users to their own topics and to topics they reply to on publication. (They can unsubscribe later if they wish.)

Thank you very much to those who contributed to me getting there.
Code is to be found here

Skip to toolbar