获取用户现有对话的线程id或不创建新对话,
$threadId = buddydev_get_threads_between_users($sender_id, $recip_id );
if(empty($threadId)){
if ( $thread_id = messages_new_message( array(\'sender_id\' => $sender_id, \'subject\' => $subject, \'content\' => $message, \'recipients\' => $recip_id ) ) ) {
bp_core_add_message( __(\'Message was sent.\', \'buddypress\' ) );
} else {
bp_core_add_message( __( \'There was an error sending Message.\', \'buddypress\' ), \'error\' );
}
}
else{
if ( messages_new_message( array(\'sender_id\' => $sender_id, \'thread_id\' => $threadId[0], \'subject\' => $subject, \'content\' => $message, \'recipients\' => $recip_id ) ) ) {
bp_core_add_message( __(\'Message was sent.\', \'buddypress\' ) );
bp_core_redirect( $bp->displayed_user->domain ); // adjust as needed
} else {
bp_core_add_message( __( \'There was an error sending Message.\', \'buddypress\' ), \'error\' );
}
}