Index: /trunk/src/bp-messages/bp-messages-functions.php
===================================================================
--- /trunk/src/bp-messages/bp-messages-functions.php	(revision 11152)
+++ /trunk/src/bp-messages/bp-messages-functions.php	(revision 11153)
@@ -237,10 +237,23 @@
 
 /**
- * Delete message thread(s).
+ * Deletes message thread(s) for a given user.
+ *
+ * Note that "deleting" a thread for a user means removing it from the user's
+ * message boxes. A thread is not deleted from the database until it's been
+ * "deleted" by all recipients.
+ *
+ * @since 2.7.0 The $user_id parameter was added. Previously the current user
+ *              was always assumed.
  *
  * @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();
+	}
 
 	/**
@@ -248,13 +261,15 @@
 	 *
 	 * @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;
 			}
@@ -269,17 +284,19 @@
 		 *
 		 * @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;
Index: /trunk/src/bp-messages/classes/class-bp-messages-thread.php
===================================================================
--- /trunk/src/bp-messages/classes/class-bp-messages-thread.php	(revision 11152)
+++ /trunk/src/bp-messages/classes/class-bp-messages-thread.php	(revision 11153)
@@ -327,12 +327,22 @@
 	 *
 	 * @since 1.0.0
+	 * @since 2.7.0 The $user_id parameter was added. Previously the current user
+	 *              was always assumed.
 	 *
 	 * @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();
+		}
 
 		/**
@@ -340,16 +350,15 @@
 		 *
 		 * @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.
@@ -399,9 +408,11 @@
 		 *
 		 * @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;
