Skip to:

11/27/2014 05:13:29 PM (9 years ago)

Post Type Activity Tracking feature

So far the tracking feature was requiring the Blogs component to be active. In 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' and to automatically generate an activity when a new item is publicly published.

It's now possible to add this support to any public post type using one unique line of code, eg: add_post_type_support( 'page', 'buddypress-activity' ). In this case BuddyPress will use generic activity attributes.
Each activity attribute of the supported post type can be customized using a specific function (eg: set custom strings to describe the post type activity action).

When registering a post type in WordPress it's also possible to set the 'buddypress-activity' feature using the support parameter of the second argument of the register_post_type() function. Custom activity action strings can be defined within the labels parameter and activity attributes can be set using the new parameter 'bp_activity'.

When the Blogs component is active, the 'post' post type is automatically supporting the 'buddypress-activity' feature. The conditional logic (eg: blog_public option set to 1 ...) that occurs before a new activity is posted and the comments tracking remain unchanged.

props boonebgorges, DJPaul

Fixes #5669

1 edited


  • trunk/tests/phpunit/testcases/blogs/activity.php

    r9139 r9194  
    33class BP_Tests_Blogs_Activity extends BP_UnitTestCase {
     4    /**
     5     * @group bp_blogs_register_activity_actions
     6     * @group activity_tracking
     7     */
     8    public function test_bp_blogs_loader_post_tracking_args_filter() {
     9        $bp = buddypress();
     11        $expected = array( 'new_blog_post', 'new_blog_comment' );
     13        if ( is_multisite() ) {
     14            $expected = array_merge( array( 'new_blog' ), $expected );
     15        }
     17        $actions = bp_activity_get_actions();
     18        $actions = array_keys( (array) $actions->blogs );
     20        $this->assertEquals( $expected, $actions );
     21    }
    423    /**
    524     * @group activity_action
Note: See TracChangeset for help on using the changeset viewer.