Opened 6 years ago
Last modified 6 years ago
#3227 new enhancement
New topic and reply notifications not sent if topic or reply published from backend
Reported by: | antipole | Owned by: | johnjamesjacoby |
---|---|---|---|
Milestone: | 2.7 | Priority: | normal |
Severity: | normal | Version: | 2.5.14 |
Component: | General - Administration | Keywords: | needs-patch |
Cc: |
Description
The bbPress Codex is quite clear that topics and replies may be published from both the front and back ends. https://codex.bbpress.org/getting-started/configuring-bbpress/creating-content/
However, I find that subscriber notifications are only sent if a topic/reply is published from the front end.
In other respects the back end does work - but no notifications are sent.
Tested with WP 4.9.8; theme twenty sixteen and only active plugins: bbPress, Stop Emails, Log emails & Reveal IDs
Change History (3)
#1
@
6 years ago
- Component changed from General to General - Administration
- Keywords needs-patch added
- Milestone changed from Awaiting Review to 2.6
- Owner set to johnjamesjacoby
#3
@
6 years ago
I have some code that is working fine for me. It hooks on to transition_post_status and so fires whenever anything changes status. You need to ignore anything that is not a topic or reply. I also have code (not shown here) to deal with WP posts that have been approved after moderation. The relevant bits of my code are:
<?php // We will will take over notification of forum and topic subscribers, so do not want bbPress to do it. remove_action( 'bbp_new_topic', 'bbp_notify_forum_subscribers', 11, 4 ); remove_action( 'bbp_new_reply', 'bbp_notify_topic_subscribers', 11, 5 ); // will act whenever a post changes status add_action( 'transition_post_status', 'submission_notifications_send_email', 10, 3 );
then in submission_notifications_send_email I have
<?php // additions notify subscribers of bbPress forum when a topic or reply is published if ('topic' === $post->post_type && 'publish' === $new_status &&'publish' !== $old_status){ $topic_id = bbp_get_topic_id( $post->ID ); $forum_id = bbp_get_topic_forum_id( $topic_id ); $author_id = bbp_get_topic_author_id($topic_id); bbp_add_user_subscription($author_id, $topic_id); // I auto subscribe authors to their own topics bbp_notify_forum_subscribers( $topic_id, $forum_id ); } elseif ('reply' === $post->post_type && 'publish' === $new_status && 'publish' !== $old_status){ $reply_id = bbp_get_topic_id( $post->ID ); $topic_id = bbp_get_reply_topic_id( $reply_id ); $forum_id = bbp_get_topic_forum_id( $topic_id ); bbp_notify_topic_subscribers( $reply_id, $topic_id, $forum_id ); } }
Note that this works for topics/replies that have been held for moderation and are then published.
Only downside is that if you edit a published topic/reply in the backend, its status seems to change from publish -> draft -> publish again, and so notifications are sent again. This does not happen if they are edited in the front end.
I hope this helps.
Confirmed.
This was an intentional decision before, but it doesn't need to be anymore.
Let's bump this to 2.7 and make it an enhancement.
I'd like to talk out how exactly this works and changes for users with specific roles, and what they should or should not be able to see and do at the same time. @antipole if you have any ideas or user stories, here is a great place to drop them!