bp_activity_comments_user_join_filter

Filters the MySQL prepared statement for the legacy activity query.

Description

Parameters (5)

0. $wpdb_prepare_select_a_u_user_email_u_user_nicename_u_user_login_u_display_name_fullname_select_from_bp_activity_table_name_a_wpdb_users_u_fullname_from_where_u_id_a_user_id_fullname_where_and_a_type_activity_comment_spam_sql_and_a_item_id_d_and_a_mptt_left_d_and_a_mptt_left_d_order_by_a_date_recorded_asc_top_level_parent_id_left_right (string)
The wpdb prepare select a u user email u user nicename u user login u display name fullname select from bp activity table name a wpdb users u fullname from where u id a user id fullname where and a type activity comment spam sql and a item id d and a mptt left d and a mptt left d order by a date recorded asc top level parent id left right.
1. $activity_id (int)
Activity ID to fetch comments for.
2. $left (int)
Left-most node boundary.
3. $right (int)
Right-most node boundary.
4. $spam_sql (string)
SQL Statement portion to differentiate between ham or spam.

Usage

To run the hook, copy the example below.
  1. $wpdb_prepare_select_a_u_user_email_u_user_nicename_u_user_login_u_display_name_fullname_select_from_bp_activity_table_name_a_wpdb_users_u_fullname_from_where_u_id_a_user_id_fullname_where_and_a_type_activity_comment_spam_sql_and_a_item_id_d_and_a_mptt_left_d_and_a_mptt_left_d_order_by_a_date_recorded_asc_top_level_parent_id_left_right = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb_prepare_select_a_u_user_email_u_user_nicename_u_user_login_u_display_name_fullname_select_from_bp_activity_table_name_a_wpdb_users_u_fullname_from_where_u_id_a_user_id_fullname_where_and_a_type_activity_comment_spam_sql_and_a_item_id_d_and_a_mptt_left_d_and_a_mptt_left_d_order_by_a_date_recorded_asc_top_level_parent_id_left_right, $activity_id, $left, $right, $spam_sql ); 
  2.  
  3. if ( !empty( $wpdb_prepare_select_a_u_user_email_u_user_nicename_u_user_login_u_display_name_fullname_select_from_bp_activity_table_name_a_wpdb_users_u_fullname_from_where_u_id_a_user_id_fullname_where_and_a_type_activity_comment_spam_sql_and_a_item_id_d_and_a_mptt_left_d_and_a_mptt_left_d_order_by_a_date_recorded_asc_top_level_parent_id_left_right ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the bp_activity_comments_user_join_filter callback 
  2. function filter_bp_activity_comments_user_join_filter( $wpdb_prepare_select_a_u_user_email_u_user_nicename_u_user_login_u_display_name_fullname_select_from_bp_activity_table_name_a_wpdb_users_u_fullname_from_where_u_id_a_user_id_fullname_where_and_a_type_activity_comment_spam_sql_and_a_item_id_d_and_a_mptt_left_d_and_a_mptt_left_d_order_by_a_date_recorded_asc_top_level_parent_id_left_right, $activity_id, $left, $right, $spam_sql ) { 
  3. // make filter magic happen here... 
  4. return $wpdb_prepare_select_a_u_user_email_u_user_nicename_u_user_login_u_display_name_fullname_select_from_bp_activity_table_name_a_wpdb_users_u_fullname_from_where_u_id_a_user_id_fullname_where_and_a_type_activity_comment_spam_sql_and_a_item_id_d_and_a_mptt_left_d_and_a_mptt_left_d_order_by_a_date_recorded_asc_top_level_parent_id_left_right
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'bp_activity_comments_user_join_filter', 'filter_bp_activity_comments_user_join_filter', 10, 5 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'bp_activity_comments_user_join_filter', 'filter_bp_activity_comments_user_join_filter', 10, 5 ); 

Defined (1)

The filter is defined in the following location(s).

/bp-activity/classes/class-bp-activity-activity.php  
  1. $sql = apply_filters( 'bp_activity_comments_user_join_filter', $wpdb->prepare( "SELECT a.*, u.user_email, u.user_nicename, u.user_login, u.display_name{$fullname_select} FROM {$bp->activity->table_name} a, {$wpdb->users} u{$fullname_from} WHERE u.ID = a.user_id {$fullname_where} AND a.type = 'activity_comment' {$spam_sql} AND a.item_id = %d AND a.mptt_left > %d AND a.mptt_left < %d ORDER BY a.date_recorded ASC", $top_level_parent_id, $left, $right ), $activity_id, $left, $right, $spam_sql );