Today, the Blogs component includes a set of functions and hooks to manage the tracking of publicly published posts and comments into the Activity stream.
The Core Team has been working on ways to build a more general solution so that an activity could be generated as soon as a new content is created by any of the registered post types. Most of our interesting discussions about it are available on the #3460 ticket.
3460 is a huge ticket which addresses many aspects of the work required to design this generic solution, such as how to catch the post types, their comments, or provide a management interface etc.
During the 2.1 dev-cycle we’ve decided to split this ticket into smaller tasks and use a more gradual approach.
This update is about the first step of it: ease the implementation of tracking the published post type items into the Activity stream (#5669).
Ease is the keyword, as today you can already add an activity when a content is created by a post type: see examples in this codex page. Plugins can use some hooks and some amount of lines of code to build their tracking feature and there’s a also a popular filter (
'bp_blogs_record_post_post_types') people can use to include post types when the Blogs component is active.
In our next major release, BuddyPress 2.2, we are centralizing the majority of the tracking code into the Activity component. A new set of functions and hooks has been created to catch public post types supporting the feature
'buddypress-activity', to generate an activity when a new item is publicly published and to insert a new option into the Activity dropdown filters used in the Activity Administration screens and in front-end.
This means the Blogs component, when activated, will automatically add the
'buddypress-activity' support to the “post” post type, this also means that any post type can support this feature. To do so, you only need one single line of code!
add_post_type_support( 'book', 'buddypress-activity' );
So using the above line of code will make sure an activity is posted each time an item of the supported post type is published, and will automatically create a new entry into the Activity dropdowns to filter the stream. The created activities will use, by default, very generic strings. If you need more control about the activity attributes, this codex page is explaining the extra code you’ll need to include using the new BuddyPress function
bp_activity_set_post_type_tracking_args() or the WordPress function
These improvements have been committed to trunk recently. If you are a developer or an “eager tester”, you can download the trunk version as explained in the “Development” section of the BuddyPress.org download page (make sure to use it on a dev/local/testing environment).