Override Buddypress function to change SQL conditions

By : madphp
Source: Stackoverflow.com
Question!

I�d like to add condtions to the bp_forum_topics() loop that only contain posts with certain keywords. Can anyone help me with this?

I�d like to create a custom plugin that overrides the current function bp_forum_topics() that does this. Im new to wordpress development so unsure about filters and tags. Right now it returns all topics (with the exception of loose search terms, newest, popular etc). I want to be able to return topics if the posts related to that topics contains specific search terms.

I can manage the coding for this, but what i'm unsure about is overriding the bp_forums_get_post functions while still retaining the other functions used in buddypress, such as get_avatar.

Any help would be great.

Mark

UPDATE: Here is the SQL

SELECT
  post.post_id,
  post.topic_id,
  topic.topic_title,
  post.post_text
FROM bb_posts post
LEFT JOIN bb_topics topic
  ON topic.topic_id = post.topic_id
WHERE topic_title LIKE '%searchterms%' OR post_text LIKE '%searchterms%';
By : madphp


Answers
Glad to see you've found the solution. You should put the SQL as an answer.

SELECT
  post.post_id,
  post.topic_id,
  topic.topic_title,
  post.post_text
FROM bb_posts post
LEFT JOIN bb_topics topic
  ON topic.topic_id = post.topic_id
WHERE topic_title LIKE '%searchterms%' OR post_text LIKE '%searchterms%';
By : dvb


This video can help you solving your question :)
By: admin