Forum Replies Created

Viewing 1 post (of 1 total)

You must be logged in to create new topic or reply to the topic.

  • Author
    Posts
  • in reply to: Search Buddypress members #25232
    Emmanuel Ken
    Participant
    • Topics: 0
    • Replies: 1

    Hi,

    Is it possible to enable Ivory Search’s AJAX functionality to include BuddyPress activity content in the search results?

    We’re currently using BuddyPress Global Search alongside Ivory Search. When a user presses enter after typing a query, the full search results page correctly displays activity content. However, the AJAX live search dropdown does not include any activity results.

    I attempted to use the following snippet to include activity in the AJAX results, but it doesn’t seem to be working as expected:

    // Add BuddyPress activity to Ajax search
    add_filter( ‘bp_global_search_ajax_results’, ‘include_activity_in_ajax’, 10, 2 );
    function include_activity_in_ajax( $results, $search_term ) {

    // Safety check to ensure BuddyPress is active
    if ( ! function_exists( ‘bp_has_activities’ ) ) {
    return $results;
    }

    // Query BuddyPress activity content
    if ( bp_has_activities( array(
    ‘search_terms’ => esc_attr( $search_term ),
    ‘per_page’ => 5
    ) ) ) {
    while ( bp_activities() ) {
    bp_the_activity();

    $results[] = array(
    ‘title’ => wp_strip_all_tags( bp_get_activity_content_body() ),
    ‘url’ => bp_get_activity_thread_permalink(),
    ‘type’ => ‘activity’,
    );
    }
    }

    return $results;
    }

Viewing 1 post (of 1 total)

You must be logged in to create new topic or reply to the topic.