well I was trying post the my code, but I think I spammed myself after trying to edit the reply to this …
CPT (and custom title thing)
add_action('init', 'video_register_my_cpt');
function video_register_my_cpt() {
register_post_type('video', array(
'label' => 'Videos',
'description' => 'Latest Videos',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_nav_menus' => false,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'videos'),
'query_var' => true,
'has_archive' => true,
'exclude_from_search' => false,
'supports' => array('title','editor','excerpt','trackbacks','custom-fields','comments','revisions','thumbnail','author','page-attributes','buddypress-activity'),
'bp_activity' => array(
'component_id' => buddypress()->blogs->id,
'action_id' => 'new_video',
'format_callback' => 'bp_blogs_format_activity_action_new_blog_post',
'comment_action_id' => 'new_video_comment',
'comment_format_callback' => 'bp_activity_format_activity_action_custom_post_type_comment',
'contexts' => array( 'activity', 'member' ),
'position' => 40,
),
'taxonomies' => array('video_category','video_tag'),
'labels' => array(
'name' => 'Videos',
'singular_name' => 'Video',
'menu_name' => 'Videos',
'add_new' => 'Add Video',
'add_new_item' => 'Add New Video',
'edit' => 'Edit',
'edit_item' => 'Edit Video',
'new_item' => 'New Video',
'view' => 'View Video',
'view_item' => 'View Video',
'search_items' => 'Search Videos',
'not_found' => 'No Videos Found',
'not_found_in_trash' => 'No Videos Found in Trash',
'bp_activity_admin_filter' => __( 'New video published', 'custom-domain' ),
'bp_activity_front_filter' => __( 'Videos', 'custom-domain' ),
'bp_activity_new_post' => __( '%1$s added <a href="%2$s">[Video]</a>', 'custom-domain' ),
'bp_activity_new_post_ms' => __( '%1$s added <a href="%2$s">[Video]</a>','custom-domain' ),
'bp_activity_comments_admin_filter' => __( 'Comments about video', 'custom-domain' ), // label for the Admin dropdown filter
'bp_activity_comments_front_filter' => __( 'Video Comments', 'custom-domain' ), // label for the Front dropdown filter
'bp_activity_new_comment' => __( '%1$s commented on a <a href="%2$s">video</a>', 'custom-domain' ),
'bp_activity_new_comment_ms' => __( '%1$s commented on a <a href="%2$s">[Video]</a>, on the site %3$s', 'custom-domain' )
)
) ); }
function my_video_include_post_type_title( $action, $activity ) {
if ( empty( $activity->id ) ) {
return $action;
}
if ( 'new_video' != $activity->type && 'new_video_comment' !=$activity->type ) {
return $action;
}
preg_match_all( '/<a.*?>([^>]*)<\/a>/', $action, $matches );
if ( empty( $matches[1][1] ) || '[Video]' != $matches[1][1] ) {
return $action;
}
$post_type_title = bp_activity_get_meta( $activity->id, 'post_title' );
if ( empty( $post_type_title ) ) {
switch_to_blog( $activity->item_id );
$post_type_title = get_post_field( 'post_title', $activity->secondary_item_id );
// We have a title save it in activity meta to avoid switching blogs too much
if ( ! empty( $post_type_title ) ) {
bp_activity_update_meta( $activity->id, 'post_title', $post_type_title );
}
restore_current_blog();
}
return str_replace( $matches[1][1], esc_html( $post_type_title ), $action );
}
add_filter( 'bp_activity_custom_post_type_post_action', 'my_video_include_post_type_title', 10, 2 );
BP CUSTOM
/*////////////////////////////////////////////////////////////////////////////////////////////*/
// Modifying CPT Activity Actions
/*///////////////////////////////////////////////////////////////////////////////////////////*/
function record_blogpost_activity_action( $activity_action, $post, $post_permalink ) {
global $bp;
if( $post->post_type == 'jobs' || get_post_type($post->ID) == 'jobs' ) {
$activity_action = sprintf( __( '%1$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>');
} elseif( $post->post_type == 'video' || get_post_type($post->ID) == 'video' ) {
$activity_action = sprintf( __( '%1$s posted a video', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
} elseif($post->post_type == 'post' ) {
$activity_action = sprintf( __( '%1$s posted a blog', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
}
return $activity_action;
}
add_filter('bp_blogs_activity_new_post_action', 'record_blogpost_activity_action', 11, 3);
/*////////////////////////////////////////////////////////////////////////////////////////////*/
// Modifying CPT Comment Activity Actions
/*///////////////////////////////////////////////////////////////////////////////////////////*/
function comment_activity_action( $activity_action, $post, $post_permalink ) {
global $bp;
if( $post->post_type == 'post' ) {
$activity_action = sprintf( __( '%1$s commented on %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
} elseif( $post->post_type == 'video' || get_post_type($post->ID) == 'video' ) {
$activity_action = sprintf( __( '%1$s replied on the video %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . esc_url( $post_permalink ). '">' . $post->post_title . '</a>' );
}
return $activity_action;
}
add_filter('bp_blogs_activity_new_comment_action', 'comment_activity_action', 11, 3);
/*//// ? /////*/
function bbg_record_video_post_type_comments( $post_types ) {
$post_types[] = 'video';
return $post_types;
}
//add_filter( 'bp_blogs_record_post_post_types', 'bbg_record_video_post_type_comments' );
//add_filter( 'bp_blogs_record_comment_post_types', 'bbg_record_video_post_type_comments' );
doing it this way, everything works except my custom comment action.