Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Error when saving post related to _bbp_topic_count

@bkno

Participant

Cause: bbPress::register_meta() registers the count meta (_bbp_topic_count, _bbp_reply_count, etc.) with register_meta( 'post', ... ) with no object_subtype. That attaches it to every post type. It also uses show_in_rest => true and `auth_callback => __return_false’.

That means every post’s REST response includes these keys. When anything in the editor changes meta (ACF’s _acf_changed, footnotes, and so on), the editor sends the whole meta object back. A normal post has no stored value for these keys, so core skips its “value unchanged” shortcut and runs the permission check.__return_false then refuses and the save fails with a 403.

Suggested fix: register the meta per bbPress post type with object_subtype (forum/topic/reply). Alternatively, don’t expose read-only meta in REST.

Workaround:

add_action( 'init', 'custom_scope_bbp_post_meta', 20 );
function custom_scope_bbp_post_meta() {
	if ( ! function_exists( 'bbp_get_forum_post_type' ) ) {
		return;
	}

	$post_types = array( bbp_get_forum_post_type(), bbp_get_topic_post_type(), bbp_get_reply_post_type() );

	foreach ( get_registered_meta_keys( 'post' ) as $meta_key => $args ) {
		if ( 0 !== strpos( $meta_key, '_bbp_' ) ) {
			continue;
		}

		unregister_meta_key( 'post', $meta_key );

		foreach ( $post_types as $post_type ) {
			register_post_meta( $post_type, $meta_key, $args );
		}
	}
}
Skip to toolbar