Skip to:
Content
Pages
Categories
Search
Top
Bottom

Sorting activity stream

  • Profile photo of Sweeny
    Sweeny
    Participant

    @sweeny

    Hi!

    I am using Buddypress (2.7.2) for generating an activity stream. Every new message is posted in the stream automatically. Comments are synchronizated. Example: A member is commenting an older blog post; his comment on the blog page will be posted in the activity page automatically. But this updated post (older original post and the very new comment) is not pushed upwards in the activity stream (it should be the first post in the activity stream after posting the newest comment). Can I change this sorting (by date of update, not by date of creation)? Do you have any ideas?

    Kind regards

    Alex

Viewing 1 replies (of 1 total)
  • Profile photo of Sweeny
    Sweeny
    Participant

    @sweeny

    Hi!

    It’s me again… I haven’t found a solution.

    This code should be working – but he doesn’t. Any ideas?

    add_filter( 'bp_activity_paged_activities_sql', function( $sql = null, $where_sql = null, $sort = null ) {
        $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 );

    Kind regards
    Alex

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