Skip to:
Content
Pages
Categories
Search
Top
Bottom

Activity Stream Search Term Filtering


  • @mcuk
    Participant

    @mcuk

    Hi all,

    I’m looking to have the option within the #activity-filter-by drop down in the activity stream where I can filter updates for a search term (e.g. MYWORD).

    I’ve added: <option value="-2"><?php _e( 'MYWORD', 'buddypress' ); ?></option> into members\single\activity.php in child theme.

    I’ve also got the working code below in my bp-custom.php:

    function bptest( $retval ) {
    
        if ( bp_is_user_activity() ) {
            $retval['search_terms'] = 'MYWORD';
        }
     
        return $retval;
    }
    add_filter( 'bp_after_has_activities_parse_args', 'bptest' );

    How can i link the two, so that ONLY WHEN the option is selected in the drop down, the code in bp-custom takes effect and at all other times, there is no filter active?

    Many thanks.

    WP 4.2.2
    BP 2.5.1

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

  • Henry Wright
    Moderator

    @henrywright

    I think you’ll need to use AJAX for this. Listen for the option list change in your JavaScript file, and then pass the relevant data to the server for processing.


    @mcuk
    Participant

    @mcuk

    Thanks Henry for the pointer! I’ll give it a look 🙂

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