Skip to:
Content

bbPress.org

Opened 2 years ago

Last modified 11 days ago

#3284 new enhancement

"Replies" are not informing the user about going in to moderation queue

Reported by: ajtruckle Owned by:
Milestone: 2.7 Priority: high
Severity: major Version: 2.6.1
Component: General Keywords: reporter-feedback
Cc:

Description

I started this discussion here: https://bbpress.org/forums/topic/notify-user-when-a-reply-goes-into-moderation/

When a user creates a new topic, and bbPress decides it shoudl go to moderation, it provides the user with information by way of the status area at the top of the window:

This is from template.php:

// Get the topic status
switch ( $topic_status ) {

	// Spam notice
	case bbp_get_spam_status_id() :
		$notice_text = esc_html__( 'This topic is marked as spam.', 'bbpress' );
		break;

	// Trashed notice
	case bbp_get_trash_status_id() :
		$notice_text = esc_html__( 'This topic is in the trash.', 'bbpress' );
		break;

	// Pending notice
	case bbp_get_pending_status_id() :
		$notice_text = esc_html__( 'This topic is pending moderation.', 'bbpress' );
		break;

	// Standard status
	default :
		$notice_text = '';
		break;
}

As you can see, there is are several responses given to the user which is most beneficial. For example:

https://www.publictalksoftware.co.uk/screenshots/moderation.jpg

But, when we look at replies this whole concept has been overlooked. The author of the reply is told nothing. This needs to be improved and my suggestion is in two ways:

  1. As a minimum the same feedback need to be provided to the user when a reply goes into moderation, just like it does for a new topic.
  1. Ideally, the information should be posts just after the most recent entry in the discussion (just before the now empty editor). You see, if you are making a reply on page 3 you won't see the moderation message (unless the system takes you to the very start of the topic to ensure you can see it).

I have given this a high priority because bbPress should have consistent behaviour when authoring new topics and replies. Infact, your own support forum suffers this issue. We must show the feedback message to the author when a reply goes to moderation.

Side point: I have written messages on your forum that I know have gone to moderation and they have not been approved. I do not know how many other users there are who have written valid posts only to see them completely vanish and not show up again.

Change History (15)

#1 @johnjamesjacoby
2 years ago

  • Milestone changed from 2.6.2 to 2.6.3

#2 @ajtruckle
2 years ago

I just noticed that there is already a placeholder for error messages on the reply form. For example, I had typed the same message 3 times so it triggered an error saying I had already typed that message or something. So this same location needs to be used for the moderation related messages.

#3 @johnjamesjacoby
23 months ago

  • Milestone changed from 2.6.3 to 2.6.4

This needs more work than will happen before 2.6.3 ships, so bumping to 2.6.4.

#4 @johnjamesjacoby
21 months ago

  • Milestone changed from 2.6.4 to 2.6.5

Moving open issues from 2.6.4 to 2.6.5, for 2.6.4 release today.

#5 @Clivesmith
21 months ago

I find this a problem too, I get people posting multiple times the same thing, as I am sure they think their reply has got lost. My site relies on guest posters.

Last edited 21 months ago by Clivesmith (previous) (diff)

#6 @johnjamesjacoby
17 months ago

  • Milestone changed from 2.6.5 to 2.6.6

#7 @johnjamesjacoby
17 months ago

  • Milestone changed from 2.6.6 to 2.7

Shifting this to 2.7.0 to lighten the 2.6.6 load.

#8 @Clivesmith
17 months ago

This problem was solved for me by Robin Wilson.

I allow guests to reply to topics and the moderation notice was not working, as said above.

I also use Moderation Tools by Digital Arm, I do not know if that would make any difference, this is the working code that Robin did for me.
I use a shortcode [mod-return] in a WordPress page with a permalink of ‘/moderation that thanks the person for replying and the shortcode sends them back to the topic.

Works perfectly



//add message if reply help in moderation
add_filter ('bbp_new_reply_redirect_to' , 'rew_pending_check', 30 , 3) ;

function rew_pending_check  ($reply_url, $redirect_to, $reply_id) {
        $status = get_post_status ($reply_id) ;
        $topic_id = bbp_get_reply_topic_id( $reply_id );
        if ($status == 'pending' ) {
                $reply_url = '/moderation/?moderation_pending='.$topic_id ;
        }
return $reply_url ;
}

add_shortcode ('mod-return' , 'mod_return' ) ;

function mod_return () {
        if (!empty($_REQUEST['moderation_pending'] )) {
        $topic_url         = get_permalink( $_REQUEST['moderation_pending'] );
        echo '<div class="mod-return"><a href= "'.$topic_url,'"><h2 style="color:Tomato;">Return to topic</h2></a></div>';
        }       
}
<?php

#9 @netweblogic
5 months ago

Sorry, no time to dig in and submit a proper patch atm but for those interested, this will show pending replies in a topic thread only to mods and the reply author. Additionally, a warning is added above the reply.

Hope it helps in the meantime!

<?php
/**
 * Modifies the SQL query for reply loops so that reply authors can view their own replies that are still pending
 * @param $where string
 * @param $wp_query WP_Query
 * @return string
 */
function bbp_allow_members_pending_view( $where, $wp_query ){
        global $wpdb;
        $type = $wp_query->query_vars['post_type'];
        if( $type == bbp_get_reply_post_type() && !current_user_can('moderate') && is_user_logged_in() ){
                // check reply here
                $user_id = get_current_user_id();
                $find = "{$wpdb->prefix}posts.post_author = $user_id AND {$wpdb->prefix}posts.post_status = 'private'";
                $replace = $find . $wpdb->prepare(" OR {$wpdb->prefix}posts.post_author = %d AND {$wpdb->prefix}posts.post_status = %s", $user_id, bbp_get_pending_status_id());
                $where = str_replace( $find, $replace, $where );
        }
        return $where;
}
add_action('posts_where', 'bbp_allow_members_pending_view', 10, 2);

/**
 * Shows a warning above pending replies, different warning for mods and the author.
 */
function my_bbp_allow_members_pending_view_warning(){
        if( bbp_get_reply_status() == bbp_get_pending_status_id() ){
                if( current_user_can('moderate') ){
                        $warning = 'This reply is pending moderation, approve so others can see it or trash it!';
                }elseif( bbp_get_reply_author_id() == get_current_user_id() ){
                        $warning = 'This reply is pending moderation, others will see it once a moderator approves it.';
                }
                if( !empty($warning) ){
                        echo '<div class="bbp-template-notice notice"><ul><li>'.$warning.'</li></ul></div>';
                }
        }
}
add_action( 'bbp_theme_before_reply_content', 'my_bbp_allow_members_pending_view_warning');

#11 @ajtruckle
5 months ago

@netweblogic Thanks for your proposed code.

To be honest, my problem now is:

  1. I asked this a very long time ago.
  2. I know that Rob Wilson (bsp plugin) had does some stuff for this and I don't remember what.
  3. I don't know the impact of using your code verses his code.

I am not confident enough to just try your code and without some interaction from Rob I am reluctant to use it at the moment incase things break.

#12 @netweblogic
5 months ago

@ajtruckle my code does as described in my first sentence, no data gets modified

copy that snippet into a blank PHP file and upload it to wp-content/mu-plugins (create the directory if it doesn't exist).

See if it works for you, if not simply delete the file, no after-effects.

#13 @jeffr0
4 months ago

I wanted to chime in here and say that I experienced this issue with a user today. They responded to an existing topic with the word Test and from their perspective, their post vanished in thin air with no explanation. They then tried to post the same thing again and saw the duplicate post message. I had no idea what was going on and neither did they.

#14 @gabrnunes
13 days ago

@netweblogic I used your code to show the message, but none posts appear if they are with "pending" status.

Is there any way to debug and discover what happened?

#15 @netweblogic
11 days ago

@gabrnunes maybe your theme isn't firing the bbp_theme_before_reply_content action? Either that or something else is overwriting the first function in my snippet and recreating a query. I'd start by checking the first one, a simple

echo 'hello world';

will tell you if the snippet is getting fired.

For the latter, try with other plugins disabled apart from BB, a vanilla theme, and this snippet. You can use https://wordpress.org/plugins/wp-safe-mode/ a plugin I made to test it just yourself in a few clicks, not actually disabling/switching themes for everyone.

Note: See TracTickets for help on using tickets.