bbp_force_comment_status( bool $open, int $post_id )

Force comments_status to ‘closed’ for Forums post types

Description

Parameters

$open

(Required) True if open, false if closed

$post_id

(Required) ID of the post to check

Return

(bool) True if open, false if closed

Source

File: bp-forums/core/theme-compat.php

985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
function bbp_force_comment_status( $open, $post_id = 0 ) {
 
    // Get the post type of the post ID
    $post_type = get_post_type( $post_id );
 
    // Default return value is what is passed in $open
    $retval = $open;
 
    // Only force for Forums post types
    switch ( $post_type ) {
        case bbp_get_forum_post_type() :
        case bbp_get_topic_post_type() :
        case bbp_get_reply_post_type() :
            $retval = false;
            break;
    }
 
    // Allow override of the override
    return apply_filters( 'bbp_force_comment_status', $retval, $open, $post_id, $post_type );
}

Changelog

Changelog
Version Description
bbPress (r3589) 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.