bp_blogs_post_type_remove_comment( bool $deleted, int $comment_id, object $activity_post_object, string $activity_type = '' )

Remove a synced activity comment from the activity stream.


Description Description


Parameters Parameters

$deleted

(Required) True when a comment post type activity was successfully removed.

$comment_id

(Required) ID of the comment to be removed.

$activity_post_object

(Required) The post type tracking args object.

$activity_type

(Optional) The post type comment activity type.

Default value: ''


Top ↑

Return Return

(bool) True on success. False on error.


Top ↑

Source Source

File: bp-blogs/bp-blogs-functions.php

function bp_blogs_post_type_remove_comment( $deleted, $comment_id, $activity_post_object, $activity_type = '' ) {
	// Remove synced activity comments, if needed.
	if ( ! bp_disable_blogforum_comments() ) {
		// Get associated activity ID from comment meta
		$activity_id = get_comment_meta( $comment_id, 'bp_activity_comment_id', true );

		/**
		 * Delete the associated activity comment & also remove
		 * child post comments and associated activity comments.
		 */
		if ( ! empty( $activity_id ) ) {
			// fetch the activity comments for the activity item
			$activity = bp_activity_get( array(
				'in'               => $activity_id,
				'display_comments' => 'stream',
				'spam'             => 'all',
			) );

			// get all activity comment IDs for the pending deleted item
			if ( ! empty( $activity['activities'] ) ) {
				$activity_ids   = bp_activity_recurse_comments_activity_ids( $activity );
				$activity_ids[] = $activity_id;

				// delete activity items
				foreach ( $activity_ids as $activity_id ) {
					bp_activity_delete( array(
						'id' => $activity_id
					) );
				}

				// remove associated blog comments
				bp_blogs_remove_associated_blog_comments( $activity_ids );

				// rebuild activity comment tree
				BP_Activity_Activity::rebuild_activity_comment_tree( $activity['activities'][0]->item_id );

				// Set the result
				$deleted = true;
			}
		}
	}

	// Backcompat for comments about the 'post' post type.
	if ( 'new_blog_comment' === $activity_type ) {
		/**
		 * Fires after a blog comment activity item was removed from activity stream.
		 *
		 * @since 1.0.0
		 *
		 * @param int $value      ID for the blog associated with the removed comment.
		 * @param int $comment_id ID of the comment being removed.
		 * @param int $value      ID of the current logged in user.
		 */
		do_action( 'bp_blogs_remove_comment', get_current_blog_id(), $comment_id, bp_loggedin_user_id() );
	}

	return $deleted;
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.