Opened 15 years ago
Closed 14 years ago
#2340 closed defect (bug) (fixed)
bp_has_message_threads() broken for unique user id
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 1.5 | Priority: | normal |
Severity: | Version: | ||
Component: | Core | Keywords: | |
Cc: |
Description
no matter what unique user id you pass to bp_has_message_threads() only the logged in user's messages are displayed.
Untimely get_current_threads_for_user() in bp-messages-classes.php is broken. Although the function takes a unique $user_id, the sql calls in the function are hard coded to use $bp->loggedin_user->id as the id.
example:
$thread_ids = $wpdb->get_results( $wpdb->prepare( "SELECT m.thread_id, MAX(m.date_sent) AS date_sent FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d AND r.sender_only = 0 {$type_sql} GROUP BY m.thread_id ORDER BY m.date_sent DESC {$pag_sql}", $bp->loggedin_user->id ) );
should be:
$thread_ids = $wpdb->get_results( $wpdb->prepare( "SELECT m.thread_id, MAX(m.date_sent) AS date_sent FROM {$bp->messages->table_name_recipients} r, {$bp->messages->table_name_messages} m WHERE m.thread_id = r.thread_id AND r.is_deleted = 0 AND r.user_id = %d AND r.sender_only = 0 {$type_sql} GROUP BY m.thread_id ORDER BY m.date_sent DESC {$pag_sql}", $user_id ) );
There's a lot of instances where the logged in user id is hardcoded all the way up the template chain - those will take longer to fix.