phpwordpressbuddypressbbpress

Buddypress force groups to have forum


I'm running a BuddyPress installation with BBPress. In step 3 of the Group Creation, there is an option to add a forum for that group and I want all groups to have a forum, so I'm customising the BuddyPress file for groups; create.php and I found that the relevant code for the "should this group have a forum"-checkbox is there. I've tried setting the checked="checked"-attribute but nothing's changed.

I want to have it checked by default and then hidden with CSS, this way the user doesn't even see the choice and the forum gets created along with the group.

The according code:

<p><?php _e( 'Should this group have a forum?', 'buddypress' ); ?></p>

<div class="checkbox">
    <label for="group-show-forum"><input type="checkbox" name="group-show-forum" id="group-show-forum" value="1" checked="checked" <?php checked( bp_get_new_group_enable_forum(), true, true ); ?> /> <?php _e( 'Enable discussion forum', 'buddypress' ); ?></label>
</div>

Solution

  • You are setting checked twice. Try:

    <input type="checkbox" name="group-show-forum" id="group-show-forum" value="1" checked="checked" /> <?php _e( 'Enable discussion forum', 'buddypress' ); ?>
    

    Or, instead of hacking create.php, use the filter hook: apply_filters( 'bp_get_new_group_enable_forum', $forum );

    function james_default_enable_forum( $forum ) {
        $forum = 1;
        return $forum;
    }
    add_filter( 'bp_get_new_group_enable_forum', 'james_default_enable_forum', 10, 1 );