Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • KZeni
    Participant

    @kzeni

    Turns out there was an issue I didn’t catch until I noticed @mentions were showing up for more than just the specified user. Below is the updated code (really, it’s just a matter of swapping out $user_id for $filter_array[‘user_id’] in the edited code mentioned above). This is working on BuddyPress 1.7.1.

    I opened up buddypress/bp-activity/bp-activity-classes.php, found lines 620-624 (part of the get_filter_sql function), and changed it from:

    if ( !empty( $filter_array['user_id'] ) ) {
    	$user_sql = BP_Activity_Activity::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] );
    	if ( !empty( $user_sql ) )
    		$filter_sql[] = $user_sql;
    }

    To:

    if ( !empty( $filter_array['user_id'] ) ) {
    	$user_sql = BP_Activity_Activity::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] );
    	// START Also include @Mentions in User Stream
    	$search_terms = '@'.bp_core_get_username($filter_array['user_id']);
    	$user_sql.= "OR ( a.content LIKE '%%".like_escape($search_terms)."%%' )";
    	// END Also include @Mentions in User Stream
    	if ( !empty( $user_sql ) )
    		$filter_sql[] = $user_sql;
    }

    KZeni
    Participant

    @kzeni

    I can’t edit my post above, but I thought I’d let you know that I’m on BuddyPress 1.7 (non-beta) now and the same edit applies & works on this version as well.


    KZeni
    Participant

    @kzeni

    Not sure if anyone else still needs the ability to combine @mentions with the personal activity stream. I took the guidance of @mattamatic with an alteration to get it working with BP 1.7 (beta 2, in my case).

    I opened up `buddypress/bp-activity/bp-activity-classes.php`, found `lines 620-624` (part of the get_filter_sql function), and changed it from:

    `if ( !empty( $filter_array[‘user_id’] ) ) {
    $user_sql = BP_Activity_Activity::get_in_operator_sql( ‘a.user_id’, $filter_array[‘user_id’] );
    if ( !empty( $user_sql ) )
    $filter_sql[] = $user_sql;
    }`

    To:

    `if ( !empty( $filter_array[‘user_id’] ) ) {
    $user_sql = BP_Activity_Activity::get_in_operator_sql( ‘a.user_id’, $filter_array[‘user_id’] );
    // START Also include @Mentions in User Stream
    $search_terms = ‘@’.bp_core_get_username($user_id);
    $user_sql.= “OR ( a.content LIKE ‘%%”.like_escape($search_terms).”%%’ )”;
    // END Also include @Mentions in User Stream
    if ( !empty( $user_sql ) )
    $filter_sql[] = $user_sql;
    }`

    Works for me on BuddyPress 1.7-beta2 (wish there was a non-hacked way to combine multiple scopes for the activity stream). Also, I should mention that you really only need to add the parts between the START/END comments, but I included the rest for context.

    Thanks again @mattamatic!

Viewing 3 replies - 1 through 3 (of 3 total)
Skip to toolbar