Skip to:
Content

bbPress.org

Opened 11 months ago

Last modified 4 months ago

#3311 new defect

Problem with custom fields for topics

Reported by: Track77 Owned by:
Milestone: Awaiting Review Priority: high
Severity: major Version: 2.6.3
Component: General Keywords:
Cc:

Description

Custom Field doesn’t work with bbpress 2.6 and above
I use custom fields for bbpress topics.
I tried to turn off all plugins and change the theme to default but always receive next javascript error in the console:

<?php
POST https://test.3d-kstudio.com/wp-admin/admin-ajax.php 400
load-scripts.php?c=0&load[chunk_0]=jquery-core,jquery-migrate,utils,suggest,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse&ver=5.3.2:4


PS. I added support to custom-fields using this code

<?php
add_filter('bbp_get_topic_post_type_supports', 'register_bbpress_topic_type_supports');
function register_bbpress_topic_type_supports( $args ) {
        $args[] = 'excerpt';
        $args[] = 'thumbnail';
        $args[] = 'custom-fields';
        return $args ;
}

Attachments (1)

Change History (4)

#1 @Track77
11 months ago

Reproducing the bug:
Create or edit an existing bbpress topic.
Try to add or edit any custom field.
This will not work.
In the browser's console, you can see the message posted above.

#2 @Track77
4 months ago

This is a difference in sent request data

BBpress 2.6 ( doesn't work )

<?php
[04-Aug-2020 10:45:52 UTC] Array
(
    [_ajax_nonce] => dafc2b7eea
    [action] => **add-reply**
    [_ajax_nonce-add-meta] => 44d3f75a6c
    [meta] => Array
        (
            [266039] => Array
                (
                    [key] => main_feature
                    [value] => Updates for \'Save/Export Selected\'.  Supports to Substance2 and more.
                )

        )

    [post_id] => 14726
    [woocommerce-login-nonce] => 
    [_wpnonce] => 
    [woocommerce-reset-password-nonce] => 
)

BBpress 2.5 ( work )

<?php
[04-Aug-2020 10:47:38 UTC] Array
(
    [_ajax_nonce] => dafc2b7eea
    [action] => **add-meta**
    [_ajax_nonce-add-meta] => 44d3f75a6c
    [meta] => Array
        (
            [266039] => Array
                (
                    [key] => main_feature
                    [value] => Updates for \'Save/Export Selected\'.  Supports to Substance2 and more.
                )

        )

    [post_id] => 14726
    [woocommerce-login-nonce] => 
    [_wpnonce] => 
    [woocommerce-reset-password-nonce] => 
)

#3 @Track77
4 months ago

Currently, this bug can be fixed using the code below.
Also, Replies box should be moved below Custom Fields

<?php
/* Fix BBpress 2.6 bug with Custom Fields */
if( function_exists( 'bbp_get_version' ) && version_compare( bbp_get_version(), '2.5' ) > 0 ) {
        add_action( 'wp_ajax_add-reply', 'wp_ajax_add_fix_bbpress_26');
        function wp_ajax_add_fix_bbpress_26() {
                // print_error_log( $_POST );
        //      $_POST['action'] = 'add-meta';
                wp_ajax_add_meta();
        }

        add_action( 'wp_ajax_delete-reply', 'wp_ajax_delete_fix_bbpress_26');
        function wp_ajax_delete_fix_bbpress_26() {
                // print_error_log( $_POST );
                wp_ajax_delete_meta();
        }

        add_action( 'add_meta_boxes', 'bbpress_26_fix_add_meta_boxes', 25 );
        function bbpress_26_fix_add_meta_boxes() {
                do_action( 'bbp_topic_attributes_metabox' );
        }
}
Note: See TracTickets for help on using tickets.