bp_activity_can_comment_reply( bool|object $comment = false )

Determine whether a comment can be made on an activity reply item.

Description

Parameters

$comment

(Optional) Activity comment.

Default value: false

Return

(bool) $can_comment True if comment can receive comments, otherwise false.

Source

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

3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
function bp_activity_can_comment_reply( $comment = false ) {
 
    // Assume activity can be commented on.
    $can_comment = true;
 
    // Check that comment exists.
    if ( empty( $comment ) ) {
        $comment = bp_activity_current_comment();
    }
 
    if ( ! empty( $comment ) ) {
 
        // Fall back on current comment in activity loop.
        $comment_depth = isset( $comment->depth )
            ? intval( $comment->depth )
            : bp_activity_get_comment_depth( $comment );
 
        // Threading is turned on, so check the depth.
        if ( get_option( 'thread_comments' ) ) {
            $can_comment = (bool) ( $comment_depth < get_option( 'thread_comments_depth' ) );
 
        // No threading for comment replies if no threading for comments.
        } else {
            $can_comment = false;
        }
    }
 
    /**
     * Filters whether a comment can be made on an activity reply item.
     *
     * @since BuddyPress 1.5.0
     *
     * @param bool   $can_comment Status on if activity reply can be commented on.
     * @param object $comment     Current comment object being checked on.
     */
    return (bool) apply_filters( 'bp_activity_can_comment_reply', $can_comment, $comment );
}

Changelog

Changelog
Version Description
BuddyPress 1.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.