WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm building a city portal/ social business directory with buddypress and wordpress. All business listings are stored as a custom post type called 'business'. I'm using the following code to show the activity related to business listings in the activity stream

function bbg_record_my_custom_post_type_comments( $post_types ) {
      $post_types[] = 'business';
      return $post_types;
add_filter( 'bp_blogs_record_comment_post_types', 'bbg_record_my_custom_post_type_comments' );

this is the result http://i.stack.imgur.com/Poaay.png

Right now it says

user commented on the post 'postname'

While I need it to say

user wrote a review on 'postname'

for the business post type, and

user commented on 'postname'

for other post types.

Any help is greatly appreciated.

share|improve this question
up vote 2 down vote accepted

You can filter on the action before it is saved by using add_filter on 'bp_blogs_activity_new_comment_action' as shown in bp-blogs-functions.php -> bp_blogs_record_comment()

Or you can filter before the action is displayed by using add_filter on 'bp_get_activity_action'

Probably better to do the former because you can easily check post->post_type to see if it is 'business'.

This shows how to adjust the activity action for the creation of a CPT: http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/display-custom-post-types-in-activity-feed/ You should be able to adjust that to handle comments.

share|improve this answer
Thank you so much for the help. I read the function in bp-blogs-functions.php and picked up the things I needed. :) – Gaurav Pareek Jul 16 '12 at 18:24

Thank you @shanebp for the answer. I'm posting my complete function as the answer so it can help others too(wasn't sure if I was to add it to the question itself)

function jw_record_my_custom_comments_strings($activity_action, $comment_id, $is_approved = true ) {
        global $bp;
        $recorded_comment = get_comment( $comment_id );
        // Get blog and post data
        $blog_id                = get_current_blog_id();
        $recorded_comment->post = get_post( $recorded_comment->comment_post_ID );

        if ( in_array( $recorded_comment->post->post_type, apply_filters( 'bp_blogs_record_comment_post_types', array( 'business' ) ) ) )
            $activity_action = sprintf( __( '%1$s wrote a review on, %2$s', 'buddypress' ), bp_core_get_userlink( $user_id ), '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' );

        return $activity_action;
share|improve this answer
     * Replaces activity action with dynamic activity action 
     * @uses    bp_get_activity_action() filter

function  custom_activity_action($action) { 

    $user_id =  bp_get_activity_user_id();
    $user_link = bp_core_get_userlink( $user_id );
    $activity_timestamp = bp_insert_activity_meta();

    if ($activity_type=='YOUR ACTIVITY TYPE HERE i.e activity_update'){

       $action = sprintf( __( '%s posted a snippet %2$s', 'buddypress' ), $user_link, $activity_timestamp  );

       return $action;

   return $action ; 

add_filter('bp_get_activity_action', 'custom_activity_action');
share|improve this answer
Please always explain your code. Thank you. – kaiser Sep 25 '15 at 18:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.