Skip to:
Content
Pages
Categories
Search
Top
Bottom

Modifying a BB_query on the fly?


  • [removed]
    Participant

    @litso

    Hey all,

    I’m trying to intercept certain (pre-defined bbPress) queries and filter a few results out. I figured I’ll need to register an action on ‘bb_query’, but I can’t seem to modify the actual query.

    Say I want to filter all topics by myself from the recent posts view, I registered the following:

    add_action('bb_query', 'filter_query');

    And then the code:

    function filter_query(&$obj) {

    if($obj->type == 'topic' && $obj->query_id == 'get_recent_posts') {

    //ADD "AND topic_author != 'Litso'" to the query here
    }
    }

    Can anyone point me in the right direction?

Viewing 4 replies - 1 through 4 (of 4 total)

  • [removed]
    Participant

    @litso

    So apparently you can change $obj->request, which is actually the entire parsed query ready to go. I just split it at the WHERE and added some stuff in there before returning the entire object.

    Works like a charm.


    [removed]
    Participant

    @litso

    So apparently you can change $obj->request, which is actually the entire parsed query ready to go. I just split it at the WHERE and added some stuff in there before returning the entire object.

    Works like a charm.


    kennymcnett
    Member

    @kennymcnett

    Litso, would you mind posting your code? This sounds like what I need to do, but I don’t know how to change the $obj->request like you mentioned works.


    kennymcnett
    Member

    @kennymcnett

    Litso, would you mind posting your code? This sounds like what I need to do, but I don’t know how to change the $obj->request like you mentioned works.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar