Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer

 
discard

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.