bp_activity_post_type_remove_comment( int $comment_id, object|null $activity_post_object = null )
Remove an activity item when a comment about a post type is deleted.
Description
Parameters
- $comment_id
-
(Required) ID of the comment.
- $activity_post_object
-
(Optional) The post type tracking args object.
Default value: null
Return
(bool) True on success. False on error.
Source
File: bp-activity/bp-activity-functions.php
function bp_activity_post_type_remove_comment( $comment_id = 0, $activity_post_object = null ) {
if ( empty( $activity_post_object ) ) {
$comment = get_comment( $comment_id );
if ( ! $comment ) {
return;
}
$post_type = get_post_type( $comment->comment_post_ID );
if ( ! $post_type ) {
return;
}
// Get the post type tracking args.
$activity_post_object = bp_activity_get_post_type_tracking_args( $post_type );
// Bail if the activity type does not exist
if ( empty( $activity_post_object->comments_tracking->action_id ) ) {
return false;
}
}
// Set the $activity_comment_object
$activity_comment_object = $activity_post_object->comments_tracking;
if ( empty( $activity_comment_object->action_id ) ) {
return false;
}
$deleted = false;
if ( bp_disable_blogforum_comments() ) {
$deleted = bp_activity_delete_by_item_id( array(
'item_id' => get_current_blog_id(),
'secondary_item_id' => $comment_id,
'component' => $activity_comment_object->component_id,
'type' => $activity_comment_object->action_id,
'user_id' => false,
) );
}
/**
* Fires after the custom post type comment activity was removed.
*
* @since BuddyPress 2.5.0
*
* @param bool $deleted True if the activity was deleted false otherwise
* @param WP_Comment $comment Comment object.
* @param object $activity_post_object The post type tracking args object.
* @param string $value The post type comment activity type.
*/
do_action( 'bp_activity_post_type_remove_comment', $deleted, $comment_id, $activity_post_object, $activity_comment_object->action_id );
return $deleted;
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.5.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.