bp_blogs_disable_activity_commenting( bool $retval )

Disable activity commenting for blog posts based on certain criteria.


Description Description

If activity commenting is enabled for blog posts, we still need to disable commenting if:

  • comments are disabled for the WP blog post from the admin dashboard
  • the WP blog post is supposed to be automatically closed from comments based on a certain age
  • the activity entry is a ‘new_blog_comment’ type

Parameters Parameters

$retval

(Required) Is activity commenting enabled for this activity entry.


Top ↑

Return Return

(bool)


Top ↑

Source Source

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

function bp_blogs_disable_activity_commenting( $retval ) {
	global $activities_template;

	// If activity commenting is disabled, return current value.
	if ( bp_disable_blogforum_comments() || ! isset( $activities_template->in_the_loop ) ) {
		return $retval;
	}

	$type = bp_get_activity_type();

	// It's a post type supporting comment tracking.
	if ( bp_activity_type_supports( $type, 'post-type-comment-tracking' ) ) {
		// The activity type is supporting comments or replies
		if ( bp_activity_type_supports( $type, 'post-type-comment-reply' ) ) {
			// Setup some globals we'll need to reference later.
			bp_blogs_setup_activity_loop_globals( $activities_template->activity );

			// If comments are closed for the WP blog post, we should disable
			// activity comments for this activity entry.
			if ( ! isset( buddypress()->blogs->allow_comments[ bp_get_activity_id() ] ) || ! buddypress()->blogs->allow_comments[ bp_get_activity_id() ] ) {
				$retval = false;
			}

			// If comments need moderation, disable activity commenting.
			if ( isset( buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) && buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) {
				$retval = false;
			}
		// The activity type does not support comments or replies
		} else {
			$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.