bbPress and Oasis Workflow compatibility

Oasis Workflow can be used to add review functionality to bbPress forum Replies. To do so follow these steps:

Step 1: Enabling the Gutenberg (block) editor for a Replies post type

  • The post type must be enabled in the REST API because Gutenberg uses REST API. For this, you need to set the show_in_rest parameter to true for the Replies custom post type.
  • The post type must also support the editor, otherwise, the editor won’t appear on the post editing screen. For this, you need to add editor to the supports parameter (which is an array) when registering the post type.
  • You can do the above via custom code as follows:
add_action( 'bbp_get_reply_post_type_supports', 'bbpress_enable_custom_fields' );
add_action( 'bbp_register_reply_post_type', 'bbpress_enable_show_in_rest');

function bbpress_enable_show_in_rest( $definition ) {
	$definition['show_in_rest'] = true;
	return $definition;
}

function bbpress_enable_custom_fields( $supports ) {
	array_push( $supports, 'custom-fields' );
	return $supports;
}

Step 2: Update the topic and forum metadata after the reply is published via workflow.

To do so, implement ‘owf_workflow_complete’ hook as follows:


add_action( "owf_workflow_complete", "bbpress_update_post_meta", 10, 2 );  

function bbpress_update_post_meta( $post_id, $action_history_id ) {
   $post = get_post( $post_id );
   if ($post && ($post->post_type == bbp_get_reply_post_type())) {
      bbp_update_reply($post_id);
      bbp_update_topic_reply_count($post_id);
      bbp_update_forum_reply_count(bbp_get_reply_forum_id($post_id));
   }
}

Didn't find what you are looking for? Submit a Query

Working with WorkflowsCustom Post Type Support