Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been trying to figure this out for weeks now and can't get it figured out. Ideally I like to filter the activity post by: today, week, month, and year. If anyone could please point me in the right direction, I'd greatly appriciate it. Thanks in advance.

share

migration rejected from stackoverflow.com Aug 6 at 18:43

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by G. M., birgire, toscho Aug 6 at 18:43

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

One approach you can take is add your options to the dropdown box, then filter into bp_ajax_querystring make sure that you set it up to high enough priority so that you get it pre-populated by the default handler.

In your filter modify the query string to include specific actvity ids, which you can pull from the database directly.

Maybe there's an easier approach but this one is most flexible (allows maximum customization)

below is one of my filters doing something similar note that I have hardcoded the include

    /* process query string main filtering happens here */

    function fp_qs_filter($qs, $obj) {



        $scope=""; // our filter

        // if activity and not global
        $displayed_user = bp_displayed_user_id();
        if ($obj== 'activity' && (!empty($displayed_user)))  {

            $scope = 'include=18';


        }

        if ($obj == 'members') {

//                $scope = 'include=1';
        }




        // if we're filtering and we have additional parameters separate them by &
        $sep = (!empty($scope) && !empty($qs))  ? "&" :"";
        $nqs = $scope . $sep . $qs;
        var_dump($nqs. ' - '.  $obj);
        return $nqs;
    }
    add_filter('bp_ajax_querystring', 'fp_qs_filter', 99,2); // make sure the filter fires as last
share
    
Piotr Kaluza, could you please explain how to use your example to add filter, which would return activities of the specific groups? –  user15792 May 3 '12 at 15:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.