Index: src/bp-messages/bp-messages-functions.php
===================================================================
--- src/bp-messages/bp-messages-functions.php	(revision 11038)
+++ src/bp-messages/bp-messages-functions.php	(working copy)
@@ -238,24 +238,34 @@
 /**
  * Delete message thread(s).
  *
+ * @since 2.7.0 The $user_id parameter was added.
+ *
  * @param int|array $thread_ids Thread ID or array of thread IDs.
+ * @param int       $user_id    ID of the user to delete the threads for. Defaults
+ *                              to the current logged-in user.
  * @return bool True on success, false on failure.
  */
-function messages_delete_thread( $thread_ids ) {
+function messages_delete_thread( $thread_ids, $user_id = 0 ) {
 
+	if ( empty( $user_id ) ) {
+		$user_id = bp_loggedin_user_id();
+	}
+
 	/**
 	 * Fires before specified thread IDs have been deleted.
 	 *
 	 * @since 1.5.0
+	 * @since 2.7.0 The $user_id parameter was added.
 	 *
-	 * @param int|array Thread ID or array of thread IDs that were deleted.
+	 * @param int|array $thread_ids Thread ID or array of thread IDs to be deleted.
+	 * @param int       $user_id    ID of the user the threads are being deleted for.
 	 */
-	do_action( 'messages_before_delete_thread', $thread_ids );
+	do_action( 'messages_before_delete_thread', $thread_ids, $user_id );
 
 	if ( is_array( $thread_ids ) ) {
 		$error = 0;
 		for ( $i = 0, $count = count( $thread_ids ); $i < $count; ++$i ) {
-			if ( ! BP_Messages_Thread::delete( $thread_ids[$i] ) ) {
+			if ( ! BP_Messages_Thread::delete( $thread_ids[$i], $user_id ) ) {
 				$error = 1;
 			}
 		}
@@ -268,19 +278,21 @@
 		 * Fires after specified thread IDs have been deleted.
 		 *
 		 * @since 1.0.0
+		 * @since 2.7.0 The $user_id parameter was added.
 		 *
 		 * @param int|array Thread ID or array of thread IDs that were deleted.
+		 * @param int       ID of the user that the threads were deleted for.
 		 */
-		do_action( 'messages_delete_thread', $thread_ids );
+		do_action( 'messages_delete_thread', $thread_ids, $user_id );
 
 		return true;
 	} else {
-		if ( ! BP_Messages_Thread::delete( $thread_ids ) ) {
+		if ( ! BP_Messages_Thread::delete( $thread_ids, $user_id ) ) {
 			return false;
 		}
 
 		/** This action is documented in bp-messages/bp-messages-functions.php */
-		do_action( 'messages_delete_thread', $thread_ids );
+		do_action( 'messages_delete_thread', $thread_ids, $user_id );
 
 		return true;
 	}
@@ -604,4 +616,4 @@
 	 */
 	do_action( 'bp_messages_sent_notification_email', $recipients, '', '', $args );
 }
-add_action( 'messages_message_sent', 'messages_notification_new_message', 10 );
\ No newline at end of file
+add_action( 'messages_message_sent', 'messages_notification_new_message', 10 );
Index: src/bp-messages/classes/class-bp-messages-thread.php
===================================================================
--- src/bp-messages/classes/class-bp-messages-thread.php	(revision 11038)
+++ src/bp-messages/classes/class-bp-messages-thread.php	(working copy)
@@ -326,31 +326,39 @@
 	 * has marked the thread as deleted.
 	 *
 	 * @since 1.0.0
+	 * @since 2.7.0 The $user_id parameter was added.
 	 *
 	 * @param int $thread_id The message thread ID.
+	 * @param int $user_id The ID of the user in the thread to mark messages as
+	 *                     deleted for. Defaults to the current logged-in user.
+	 *
 	 * @return bool
 	 */
-	public static function delete( $thread_id = 0 ) {
+	public static function delete( $thread_id = 0, $user_id = 0 ) {
 		global $wpdb;
 
 		$thread_id = (int) $thread_id;
+		$user_id = (int) $user_id;
 
+		if ( empty( $user_id ) ) {
+			$user_id = bp_loggedin_user_id();
+		}
+
 		/**
 		 * Fires before a message thread is marked as deleted.
 		 *
 		 * @since 2.2.0
+		 * @since 2.7.0 The $user_id parameter was added.
 		 *
 		 * @param int $thread_id ID of the thread being deleted.
+		 * @param int $user_id   ID of the user that the thread is being deleted for.
 		 */
-		do_action( 'bp_messages_thread_before_mark_delete', $thread_id );
+		do_action( 'bp_messages_thread_before_mark_delete', $thread_id, $user_id );
 
 		$bp = buddypress();
 
 		// Mark messages as deleted
-		//
-		// @todo the reliance on bp_loggedin_user_id() sucks for plugins
-		// refactor this method to accept a $user_id parameter.
-		$wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, bp_loggedin_user_id() ) );
+		$wpdb->query( $wpdb->prepare( "UPDATE {$bp->messages->table_name_recipients} SET is_deleted = 1 WHERE thread_id = %d AND user_id = %d", $thread_id, $user_id ) );
 
 		// Get the message ids in order to pass to the action.
 		$message_ids = $wpdb->get_col( $wpdb->prepare( "SELECT id FROM {$bp->messages->table_name_messages} WHERE thread_id = %d", $thread_id ) );
@@ -398,11 +406,13 @@
 		 * Fires after a message thread is either marked as deleted or deleted.
 		 *
 		 * @since 2.2.0
+		 * @since 2.7.0 The $user_id parameter was added.
 		 *
 		 * @param int   $thread_id   ID of the thread being deleted.
 		 * @param array $message_ids IDs of messages being deleted.
+		 * @param int   $user_id     ID of the user the threads were deleted for.
 		 */
-		do_action( 'bp_messages_thread_after_delete', $thread_id, $message_ids );
+		do_action( 'bp_messages_thread_after_delete', $thread_id, $message_ids, $user_id );
 
 		return true;
 	}
