Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Comments not showing up on activity stream

@danbp

Participant

hi @mjc82in,

BuddyPress is continuously evolving. 2 years back it was a mess trying to use CPT on SWA. That’s no more the case with BP 2.2

Maybe this example will help you. It creates a CPT called Music which will show up on the SWA where you can comment it.

Add the code to bp-custom.php

// allow tracking of our CPT
add_post_type_support( 'music', 'buddypress-activity' );

function customize_page_tracking_args() {
    // Check if the Activity component is active before using it.
    if ( ! bp_is_active( 'activity' ) ) {
        return;
    }
 
    bp_activity_set_post_type_tracking_args( 'music', array(
        'component_id'             => 'activity',
        'action_id'                => 'new_music',
        'bp_activity_admin_filter' => __( 'Published a new music', 'text-domain' ),
        'bp_activity_front_filter' => __( 'Music', 'text-domain' ),
			'contexts'                 => array( 'activity', 'member' ),
			'activity_comment'         => true,
			'bp_activity_new_post'     => __( '%1$s posted a new <a href="%2$s">Music</a>', 'text-domain' ),
			'bp_activity_new_post_ms'  => __( '%1$s posted a new <a href="%2$s">Music</a>, on the site %3$s', 'text-domain' ),
			'position'                 => 800,
    ) );
}
add_action( 'init', 'customize_page_tracking_args', 999 );

function bpfr_create_post_type() {
  register_post_type( 'music',
    array(
      'labels' => array(
        'name' => __( 'Music', 'text-domain' ),
        'singular_name' => __( 'Music', 'text-domain' )
      ),
      'public' => true,
      'has_archive' => true,
    )
  );
}
add_action( 'init', 'bpfr_create_post_type' );

Ref: https://codex.buddypress.org/plugindev/post-types-activities/

Skip to toolbar