Advertisement
Guest User

activities updates from all comments Buddypress 2.1.1

a guest
Oct 19th, 2014
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.21 KB | None | 0 0
  1. /**
  2.  * Buddypress: Crear actividades para nuevos comentarios Creados En La Actividad
  3.  * https://buddypress.org/support/topic/blog-comments-not-appearing-in-activity-stream/#post-186094
  4.  */
  5. add_filter( 'bp_ajax_querystring', 'bpfr_stream', 20, 2 );
  6. function bpfr_stream( $qs, $object ) {
  7.     if ( 'activity' != $object ) {
  8.         return $qs;
  9.     }
  10.     $qs = wp_parse_args( $qs, array() );
  11.     $qs['display_comments'] = 'stream';
  12.     return $qs;
  13. }
  14.  
  15.  
  16. /**
  17.  * Buddypress: Crear actividades para nuevos comentarios Creados En El Post
  18.  * https://buddypress.org/support/topic/blog-post-comments-not-update-activity-comments/#post-218766
  19.  */
  20.  
  21. /*
  22.  * When a new comment gets added to the database, add this comment to the
  23.  * activity stream
  24.  */
  25. function bca_record_activity($comment_id, $approval) {
  26.     if($approval == 1) {
  27.         $comment = get_comment($comment_id);
  28.         $userlink = bp_core_get_userlink($comment->user_id);
  29.         $postlink = '<a href="' . get_permalink($comment->comment_post_ID) . '">'
  30.                         . get_the_title($comment->comment_post_ID) . '</a>';
  31.  
  32.         bp_activity_add(array(
  33.             'action'            => sprintf( __( '%1$s commented on the post, %2$s', 'buddypress' ),
  34.                                                 $userlink, $postlink),
  35.             'content'           => $comment->comment_content,
  36.             'component'         => 'bp_plugin',
  37.             'user_id'           => $comment->user_id,
  38.             'type'              => 'new_blog_comment',
  39.  
  40.         ));
  41.      
  42.     }
  43. }
  44. //comment_post is triggered "just after a comment is saved in the database".
  45. add_action('comment_post', 'bca_record_activity', 10, 2);
  46.  
  47. /*
  48.  * We want activity entries of blog comments to be shown as "mini"-entries
  49.  */
  50. function bca_minify_activity($array) {
  51.     $array[] = 'new_blog_comment';
  52.     return $array;
  53. }
  54. add_filter('bp_activity_mini_activity_types', 'bca_minify_activity');
  55.  
  56. /*
  57.  * Disables comments on this type of activity entry
  58.  */
  59. function bca_remove_commenting($can_comment) {
  60.     if($can_comment == true) {
  61.         $can_comment = ! ('new_blog_comment' == bp_get_activity_action_name());
  62.     }
  63.     return $can_comment;
  64. }
  65. add_filter('bp_activity_can_comment', 'bca_remove_commenting');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement