Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Adding custom taxonomies to Topic form

@robin-w

Moderator

some code from one of my plugins (bbp-style-pack) that plays with this area might help

add_action ('bbp_new_topic_post_extras' , 'bsp_topic_tags_process' ) ;
	add_action ('bbp_edit_topic_post_extras' , 'bsp_topic_tags_process' ) ;
	add_action( 'bbp_new_reply_post_extras', 'bsp_reply_tags_process' );
	add_action( 'bbp_edit_reply_post_extras', 'bsp_reply_tags_process' );

//handle topic tags

function bsp_topic_tags_process ($topic_id) {
	if ( bbp_allow_topic_tags() && ! empty( $_POST['bbp_topic_tags'] ) ) {
		
		$terms = $_POST['bbp_topic_tags'] ;
		
		// Add topic tag ID as main key
		$terms = array( bbp_get_topic_tag_tax_id() => $terms );
		
		$topic_data = array(
		'ID'           => $topic_id,
		'tax_input'    => $terms,
		) ;
		$topic_id = wp_update_post( $topic_data );
		
		
	}
}

function bsp_reply_tags_process ($reply_id) {
	if ( bbp_allow_topic_tags() && ! empty( $_POST['bbp_topic_tags'] ) ) {
		$topic_id = bbp_get_reply_topic_id ($reply_id) ;
		
		$terms = $_POST['bbp_topic_tags'] ;
		
		// Add topic tag ID as main key
		$terms = array( bbp_get_topic_tag_tax_id() => $terms );
		
		$topic_data = array(
		'ID'           => $topic_id,
		'tax_input'    => $terms,
		) ;
		$topic_id = wp_update_post( $topic_data );
	}
}
Skip to toolbar