bp_blogs_remove_activity_meta_for_trashed_comments( int $post_id, array $comments = array() )
When a post is trashed, remove each comment’s associated activity meta.
Description
When a post is trashed and later untrashed, we currently don’t reinstate activity items for these comments since their activity entries are already deleted when initially trashed.
Since these activity entries are deleted, we need to remove the deleted activity comment IDs from each comment’s meta when a post is trashed.
Parameters
- $post_id
-
(Required) The post ID.
- $comments
-
(Optional) Array of comment statuses. The key is comment ID, the value is the $comment->comment_approved value.
Default value: array()
Source
File: bp-blogs/bp-blogs-activity.php
function bp_blogs_remove_activity_meta_for_trashed_comments( $post_id = 0, $comments = array() ) { if ( ! empty( $comments ) ) { foreach ( array_keys( $comments ) as $comment_id ) { delete_comment_meta( $comment_id, 'bp_activity_comment_id' ); } } }
Changelog
Version | Description |
---|---|
BuddyPress 2.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.