Reply To: CPT in Activity with Detail
Sure. I finally got back to this and spent some time debugging it. I had assumed that the meta box fields would be available but in retrospect that was not a good assumption (why would they, right?). Once I figured that out I just wrote some code to retrieve the fields I needed. If you use $activity->secondary_item_id you can pull in the data you need from the original meta box fields.
The final code from my tests is below.
I hope this helps. And, thanks to Shane for putting me on the right path.
function ben_filter_activity_body( $content, $activity ) {
$checkintext = "";
if ( 'new_check_in' === $activity->type ) {
if ( isset( $activity->secondary_item_id ) ) {
$current_post = $activity->secondary_item_id;
$beerName = get_post_meta($current_post, 'check_in_details_beer-name', true);
$barName = get_post_meta($current_post, 'check_in_details_bar-name', true);
$beerRating = get_post_meta($current_post, 'check_in_details_rating', true);
$beerReview = get_post_meta($current_post, 'check_in_details_notes', true);
$checkintext = "Drank: " . $beerName . " At: " . $barName . "<br />Rated it: " . $beerRating . "<br />Review: " . $beerReview;
}
$content = 'Note: (ID:'. $activity->secondary_item_id . ')' . $content . $checkintext;
}
return $content;
}
add_filter( 'bp_get_activity_content_body', 'ben_filter_activity_body', 25, 2 );