bp_blogs_can_comment_reply( bool $retval, object|array $comment )

Check if an activity comment associated with a blog post can be replied to.


Description Description

By default, disables replying to activity comments if the corresponding WP blog post no longer accepts comments.

This check uses a locally-cached value set in bp_blogs_disable_activity_commenting() via bp_blogs_setup_activity_loop_globals().


Top ↑

Parameters Parameters

$retval

(bool) (Required) Are replies allowed for this activity reply.

$comment

(object|array) (Required) The activity comment object.


Top ↑

Return Return

(bool)


Source Source

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

function bp_blogs_can_comment_reply( $retval, $comment ) {
	if ( is_array( $comment ) ) {
		$comment = (object) $comment;
	}

	// Check comment depth and disable if depth is too large.
	if ( isset( buddypress()->blogs->thread_depth[$comment->item_id] ) ){
		if ( bp_activity_get_comment_depth( $comment ) >= buddypress()->blogs->thread_depth[$comment->item_id] ) {
			$retval = false;
		}
	}

	// Check if we should disable activity replies based on the parent activity.
	if ( isset( buddypress()->blogs->allow_comments[$comment->item_id] ) ){
		// The blog post has closed off commenting, so we should disable all activity
		// comments under the parent 'new_blog_post' activity entry.
		if ( ! buddypress()->blogs->allow_comments[ $comment->item_id ] ) {
			$retval = false;
		}
	}

	// If comments need moderation, disable activity commenting.
	if ( isset( buddypress()->blogs->comment_moderation[ $comment->item_id ] ) && buddypress()->blogs->comment_moderation[ $comment->item_id ] ) {
		$retval = false;
	}

	return $retval;
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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