bp_activity_add_notification_for_synced_blog_comment

Add a notification for post comments to the post author or post commenter.

Description

bp_activity_add_notification_for_synced_blog_comment( (int) $activity_id, (WP_Comment) $post_type_comment, (array) $activity_args, (object) $activity_post_object ); 

Requires activity stream commenting on blog and forum posts to be enabled.

Parameters (4)

0. $activity_id (int)
The activity comment ID.
1. $post_type_comment (WP_Comment)
The post type comment.
2. $activity_args (array)
Activity comment arguments.
3. $activity_post_object (object)
The post type tracking args object.

Usage

  1. if ( !function_exists( 'bp_activity_add_notification_for_synced_blog_comment' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-notifications.php'; 
  3.  
  4. // The activity comment ID. 
  5. $activity_id = -1; 
  6.  
  7. // The post type comment. 
  8. $post_type_comment = null; 
  9.  
  10. // Activity comment arguments. 
  11. $activity_args = array(); 
  12.  
  13. // The post type tracking args object. 
  14. $activity_post_object = null; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = bp_activity_add_notification_for_synced_blog_comment($activity_id, $post_type_comment, $activity_args, $activity_post_object); 
  18.  

Defined (1)

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

/bp-activity/bp-activity-notifications.php  
  1. function bp_activity_add_notification_for_synced_blog_comment( $activity_id, $post_type_comment, $activity_args, $activity_post_object ) { 
  2. // If activity comments are disabled for WP posts, stop now! 
  3. if ( bp_disable_blogforum_comments() || empty( $activity_id ) ) { 
  4. return; 
  5.  
  6. // Send a notification to the blog post author. 
  7. if ( (int) $post_type_comment->post->post_author !== (int) $activity_args['user_id'] ) { 
  8. // Only add a notification if comment author is a registered user. 
  9. // @todo Should we remove this restriction? 
  10. if ( ! empty( $post_type_comment->user_id ) ) { 
  11. 'user_id' => $post_type_comment->post->post_author,  
  12. 'item_id' => $activity_id,  
  13. 'secondary_item_id' => $post_type_comment->user_id,  
  14. 'component_name' =>buddypress)->activity->id,  
  15. 'component_action' => 'update_reply',  
  16. 'date_notified' => $post_type_comment->comment_date_gmt,  
  17. 'is_new' => 1,  
  18. ) ); 
  19.  
  20. // Send a notification to the parent comment author for follow-up comments. 
  21. if ( ! empty( $post_type_comment->comment_parent ) ) { 
  22. $parent_comment = get_comment( $post_type_comment->comment_parent ); 
  23.  
  24. if ( ! empty( $parent_comment->user_id ) && (int) $parent_comment->user_id !== (int) $activity_args['user_id'] ) { 
  25. 'user_id' => $parent_comment->user_id,  
  26. 'item_id' => $activity_id,  
  27. 'secondary_item_id' => $post_type_comment->user_id,  
  28. 'component_name' =>buddypress)->activity->id,  
  29. 'component_action' => 'comment_reply',  
  30. 'date_notified' => $post_type_comment->comment_date_gmt,  
  31. 'is_new' => 1,  
  32. ) );