Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/bp-moderation/classes/class-bp-moderation-abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,35 @@ protected function blocked_user_query() {
return false;
}

/**
* Prepare Where sql to exclude content authored by members blocked by the current user.
*
* Unlike blocked_user_query(), this condition matches on the content author's
* user id directly, so it does not depend on suspend/suspend_details entries
* being materialized for each individual content item. Since blocking a member
* no longer generates suspend entries for their existing content, this is the
* only reliable way to exclude a blocked member's content at query time.
*
* @since BuddyBoss [BBVERSION]
*
* @param string $column Fully qualified author id column (e.g. `a.user_id`).
*
* @return string|bool Where sql on success, false otherwise.
*/
protected function blocked_author_query( $column ) {
if ( empty( $column ) || ! bp_is_moderation_member_blocking_enable( 0 ) ) {
return false;
}

$hidden_users_ids = bp_moderation_get_hidden_user_ids();

if ( empty( $hidden_users_ids ) ) {
return false;
}

return "( {$column} NOT IN ( " . implode( ',', wp_parse_id_list( $hidden_users_ids ) ) . ' ) )';
}

/**
* Reporting Setting enabled for current content.
*
Expand Down
8 changes: 8 additions & 0 deletions src/bp-moderation/classes/class-bp-moderation-activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ function_exists( 'bb_did_filter' ) &&
}

$where['moderation_where'] .= '( a.user_id NOT IN ( ' . bb_moderation_get_blocked_by_sql() . ' ) )';

// Exclude activities authored by members blocked by the current user.
// Blocking no longer materializes suspend entries for the blocked member's
// existing content, so the author based condition is required to hide it.
$blocked_members_query = $this->blocked_author_query( 'a.user_id' );
if ( ! empty( $blocked_members_query ) ) {
$where['moderation_where'] .= ' AND ' . $blocked_members_query;
}
}

if ( ! empty( $exclude_group_sql ) ) {
Expand Down
Loading