The problem here is the bp_has_message_threads()
function itself. It comes with hardcoded checks to override the $box
to sentbox
or inbox
based on the results of bp_is_current_action()
.
You could try something this, in lieu of bp_has_message_threads()
:
function bp_custom_has_message_threads( $args = '' ) {
global $messages_template;
$r = wp_parse_args( $args, array(
'user_id' => bp_loggedin_user_id(),
'box' => 'inbox',
'per_page' => 10,
'max' => false,
'type' => 'all',
'search_terms' => isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '',
'page_arg' => 'mpage', // See https://buddypress.trac.wordpress.org/ticket/3679
) );
if ( bp_is_current_action( 'notices' ) && !bp_current_user_can( 'bp_moderate' ) ) {
bp_core_redirect( bp_displayed_user_domain() );
}
$messages_template = new BP_Messages_Box_Template( $r['user_id'], $r['box'], $r['per_page'], $r['max'], $r['type'], $r['search_terms'], $r['page_arg'] );
return apply_filters( 'bp_has_message_threads', $messages_template->has_threads(), $messages_template );
}
You may need to be crafty and override the BP_Messages_Box_Template()
class too, as it contains more hardcoded assumptions about what box the user is looking at.
Hmm…
yeah that’s what i thought. it might not be the easiest tasks.
It seems as if it would be something more people would have looked into, but I’ve searched high and low and no answers (or questions for that matter.)
Would you have any ideas as how to override BP_Messages_Box_Template()
class?