Skip to:
Content
Pages
Categories
Search
Top
Bottom

Private Messages: Is it possible to have a joint inbox and sentbox

  • Avatar of lonepalmus
    lonepalmus
    Participant

    @lonepalmus

    Hi guys,

    My first time writing here – hoping someone can point me in the right direction:

    I am using buddypress 1.9.2 with wordpress 3.8.1 (no link atm, as it is localhost).

    Is it possible in any way to have a page showing both sent and received messages? Kind of like Facebook – if i’ve sent a message and there’s no reply yet, i will still see my own.

    I’ve looked into bp_has_message_threads() in messages-loop.php, but there doesn’t seem to be an option to show &box=’all’ (only inbox, sentbox or notices.)

    Really hoping someone has some input. Do I have to change the way the messages are stored perhaps?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    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 );
    }
    Avatar of John James Jacoby
    John James Jacoby
    Keymaster

    @johnjamesjacoby

    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…

    Avatar of lonepalmus
    lonepalmus
    Participant

    @lonepalmus

    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?

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.