Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding activity to groups loop

  • @gwendydd

    Participant

    I am using the following code to add a custom post type to users’ activity streams:

    
    add_filter ( 'bp_blogs_record_post_post_types', 'ecomukti_activity_publish_custom_post_types',1,1 );
    function ecomukti_activity_publish_custom_post_types( $post_types ) {
    	$post_types[] = 'product';
    	return $post_types;
    }
    
    add_filter('bp_blogs_activity_new_post_action', 'ecomukti_cpt_activity_action', 1, 3);
    function ecomukti_cpt_activity_action( $activity_action,  $post, $post_permalink ) { 
        global $bp;
        if( $post->post_type == 'product' ) {
            if ( is_multisite() )
                $activity_action  = sprintf( __( '%1$s created a new campaign, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' );
            else
                $activity_action  = sprintf( __( '%1$s created a new campaign, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
        }
    
        return $activity_action;
    }
    

    However, I also want this activity to show up in the group loop for all groups the user belongs to. How can I get this to show on the group page?

    I have read the following pages, but I haven’t found them helpful:

    Add custom filters to loops and enjoy them within your plugin

    Groups Loop

  • The topic ‘Adding activity to groups loop’ is closed to new replies.
Skip to toolbar