bp_blogs_disable_activity_commenting( bool $retval )

Disable activity commenting for blog posts based on certain criteria.


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



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




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 ( empty( buddypress()->blogs->allow_comments[ bp_get_activity_id() ] ) ) {
				$retval = false;

			// If comments need moderation, disable activity commenting.
			if ( ! empty( buddypress()->blogs->comment_moderation[ bp_get_activity_id() ] ) ) {
				$retval = false;
		// The activity type does not support comments or replies
		} else {
			$retval = false;

	return $retval;


Version Description
BuddyPress 2.0.0 Introduced.


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.