Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Third-party shortcodes in bbPress posts

@chadschulz

Participant

@yo35: It can be done. But, you’ll need to either mod the plugin or insert a custom function inside your child theme (while deactivating the plugin to avoid conflicts).

the original plugin code is:

function pw_bbp_shortcodes( $content, $reply_id ) {
	
	$reply_author = bbp_get_reply_author_id( $reply_id );

	if( user_can( $reply_author, pw_bbp_parse_capability() ) )
		return do_shortcode( $content );

	return $content;
}
add_filter('bbp_get_reply_content', 'pw_bbp_shortcodes', 10, 2);
add_filter('bbp_get_topic_content', 'pw_bbp_shortcodes', 10, 2);

function pw_bbp_parse_capability() {
	return apply_filters( 'pw_bbp_parse_shortcodes_cap', 'publish_forums' );
}

What needs to change is the section returning the do_shortcode( $content ) as follows:

	if( user_can( $reply_author, pw_bbp_parse_capability() ) ) {
		$content = shortcode_unautop( $content );
		return do_shortcode( $content );
	}

This will remove the autop filter that adds <p></p> to the shortcode text.

Good luck.

Skip to toolbar