Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • subair.tc
    Participant

    @subairtc

    Any one please help me to fix this issue.


    subair.tc
    Participant

    @subairtc

    I am using WP v4.9.1 and buddypress v2.9.2, i have switched the theme into default but the issue still exist


    subair.tc
    Participant

    @subairtc

    hi @bughy,

    You got any solution for fixing this issue,
    I need a feature like admin can pin some posts on the top of the activity stream under the group activity section.

    Thanks
    Subair


    subair.tc
    Participant

    @subairtc

    hi @henrywright , @danbp

    Thanks for your great help,

    i have solved the issue without hacking the code using the

    bp_activity_paged_activities_sql

    filter in class-bp-activity-activity.php ~L, 609

    the code below is i have used, please refer this thred , where i got some information regarding filters.

    add_filter( 'bp_activity_paged_activities_sql', function( $sql, $where_sql, $sort ) {
    	$pos = strpos($sql, 'WHERE a.id IN');
    	if($pos){
    		$in_items = implode( ',', $where_sql['in'] );
    		$sql = str_replace('ORDER BY a.date_recorded DESC' ,' ORDER BY FIELD(id,'.$in_items.') ',$sql);
    	}
    	
        return $sql;
    }, 10, 3 );
    
    

    Thanks again for your valuable time and please let me know any suggestions you have 🙂


    subair.tc
    Participant

    @subairtc

    hi @danbp
    Thanks for your reply,
    i have tried the with

    bp_activity_get_where_conditions

    but this filter will return the where conditions used like

    array(3) {
      ["filter_sql"]=>
      string(416) "a.user_id IN ( 451,378,213,431,429,414,415,456,452,473,460,458,283,471,383,468,387,454,441,6,384,475,427 ) AND a.component IN ( 'groups' ) AND a.type IN ( 'activity_update' ) AND a.item_id IN ( 1 )"
      ["spam_sql"]=>
      string(13) "a.is_spam = 0"
      ["excluded_types"]=>
      string(34) "a.type NOT IN ('activity_comment')"
    }

    it will not contain the ‘ORDER BY’ portion of the query, i hope we will get the total query with the

    bp_activity_total_activities_sql

    filter in ~L, 664, so when we get the entire query we can replace the ‘ORDER BY’ section using string replace, i have tried by using this but i can’t get the query inside the function, do you have any idea how to use this filter ?


    subair.tc
    Participant

    @subairtc

    I have added the ‘include’ argument with ‘bp_has_activities’ function as

    <?php if ( bp_has_activities( bp_ajax_querystring( 'activity' ) . '&action=activity_update&include='.$sorted_ids  ) ) : ?>

    where the ‘$sorted_ids’ the comma separated activity id’s in sorted order. But unfortunatly the BuddyPress Core will sort the activities in ASC or DESC order.

    I fount the Query used in core file ‘class-bp-activity-activity.php’ inside ‘plugins\buddypress\bp-activity\classes’ on line number : 585 as

    // Query first for activity IDs.
    $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort}";
    

    and i have replaced it as

    if($in)
    $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY FIELD(id,$in)";
    else
    $activity_ids_sql = "{$select_sql} {$from_sql} {$join_sql} {$where_sql} ORDER BY a.date_recorded {$sort}, a.id {$sort}";
    
    

    Now it’s working fine for me, But it’s not recommended to modify the core file

    So please let me know if any one know the filter hook used for modifying the Query from the file itself.


    subair.tc
    Participant

    @subairtc

    Anybody Please help

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