Display Additional Post Types in Activity Stream

  • Participant
    Level: Initiated
    Posts: 17
    buddyuser on #35620


    I suppose this could be either a How-to or request depending on the extent of the task.

    I’ve looked around and couldn’t find any way to add additional post types to the buddypress activity stream.

    For example, what I’m trying to do is add freshly published/created products to appear in the activity stream.

    I’m currently using the code below to achieve this; however, it does not include the product’s title, featured image, and excerpt in the activity stream, which are very important/crucial.

    add_filter ( 'bp_blogs_record_post_post_types', 'activity_publish_custom_post_types',1,1 );
    function activity_publish_custom_post_types( $post_types ) {
        $post_types[] = 'product';
        return $post_types;
    add_filter('bp_blogs_activity_new_post_action', 'record_cpt_activity_action', 1, 3);
    function record_cpt_activity_action( $activity_action, $post, $post_permalink ) {
        global $bp;
        if( $post->post_type == 'product' ) {
            if ( is_multisite() )
                $activity_action = sprintf( __( '%1$s added or updated the product %2$s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>', get_blog_option($blog_id, 'blogname'));
            $activity_action = sprintf( __( '%1$s created a new Product post, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '' . $post->post_title . '' );
        return $activity_action;

You must be logged in to reply to this topic.

This topic is: not resolved