Skip to content

Instantly share code, notes, and snippets.

@wbcomdev
Created April 20, 2022 06:14
Show Gist options
  • Select an option

  • Save wbcomdev/b362a9061035aa4f2a026b379bbf3d5c to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/b362a9061035aa4f2a026b379bbf3d5c to your computer and use it in GitHub Desktop.
/**
* Filters the MySQL WHERE conditions for the Activity items get method.
*
* @since BuddyPress 1.9.0
*
* @param array $where_conditions Current conditions for MySQL WHERE statement.
* @param array $r Parsed arguments passed into method.
* @param string $select_sql Current SELECT MySQL statement at point of execution.
* @param string $from_sql Current FROM MySQL statement at point of execution.
* @param string $join_sql Current INNER JOIN MySQL statement at point of execution.
*/
function wbcom_hide_sticky_post_from_tabs( $where_conditions, $r, $select_sql, $from_sql, $join_sql ) {
$plugins = get_option( 'active_plugins' );
if ( in_array( 'buddypress-sticky-post/buddypress-sticky-post.php', $plugins, true ) ) {
$sticky_ids = bpsp_get_sticky_posts_ids();
if ( ! empty( $sticky_ids ) ) {
if ( 'friends' === $_REQUEST['scope'] ) { // change scope here.
$where_conditions['not_in'] = 'a.id NOT IN (' . $sticky_ids . ')';
}
} else {
return $where_conditions;
}
}
return $where_conditions;
}
add_filter( 'bp_activity_get_where_conditions', 'wbcom_hide_sticky_post_from_tabs', 10, 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment