Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm new to buddypress and had many searches over this topic. I read about Activity Stream Loop function, by its filters I can display recent activities base on new_blog_comment but I'm looking for a way to display latest activity by the recent comments posted for activities! I didn't find any filter or option about it.

Any help would be appreciated.

share|improve this question
add comment

1 Answer

add_filter ( "bp_activity_get_user_join_filter" , "tbp_activity_get_user_join_filter" , 999 , 6 ) ;

function tbp_activity_get_user_join_filter ( $sql , $select_sql , $from_sql , $where_sql , $sort , $pag_sql = '' ) {
    global $bp ;
    $select_sql .= ", COALESCE((select t.date_recorded
                        from {$bp -> activity -> table_name} t where t.type='activity_comment' and t.item_id = a.id
                        order by t.date_recorded desc limit 1) ,a.date_recorded ) as tdate_recorded " ;
    return "{$select_sql} {$from_sql} {$where_sql} ORDER BY cast(tdate_recorded as datetime) {$sort} {$pag_sql}" ;
}
share|improve this answer
    
thanks but site doesn't load (no error just it keep on loading site and nothing) with adding this snippet to functions.php –  revo Sep 5 '13 at 6:47
    
can you send me output , add following line before return : echo "{$select_sql} {$from_sql} {$where_sql} ORDER BY cast(tdate_recorded as datetime) {$sort} {$pag_sql}"; exit; –  Strik3r Sep 5 '13 at 6:56
    
SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name, COALESCE((select t.date_recorded from wp_bp_activity t where t.type='activity_comment' and t.item_id = a.id order by t.date_recorded desc limit 1) ,a.date_recorded ) as tdate_recorded FROM wp_bp_activity a LEFT JOIN wp_users u ON a.user_id = u.ID WHERE a.is_spam = 0 AND a.type IN ( 'activity_update' ) AND a.hide_sitewide = 0 AND a.type != 'activity_comment' ORDER BY cast(tdate_recorded as datetime) DESC LIMIT 0, 30 –  revo Sep 5 '13 at 7:01
    
Query is fine, hope you other plugin is not conflicting with this query, you can check output of this query in mysql console. you can change priority to 10 add_filter ( "bp_activity_get_user_join_filter" , "tbp_activity_get_user_join_filter" , 10 , 6 ) ; –  Strik3r Sep 5 '13 at 7:09
    
can you execute this query on mysql? –  Strik3r Sep 5 '13 at 7:18
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.