Created
December 14, 2016 05:21
-
-
Save Giannisduke/b462ee7eabe43c9eca17277d4747966d to your computer and use it in GitHub Desktop.
Buddypress - Change text from the activity for custom post types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 'bp_blogs_record_post_post_types', 'inspired_record_more_types' ); | |
function inspired_record_more_types( $types ) { | |
$types[] = 'projects'; | |
$types[] = 'sfwd-courses'; | |
$types[] = 'uig_image'; | |
return $types; | |
} | |
add_filter('bp_blogs_activity_new_post_action', 'record_cpt_activity_action', 1, 3); | |
function record_cpt_activity_action( $activity_action, $post, $post_permalink ) { | |
if( $post->post_type == 'projects' ) { | |
$activity_action = sprintf( __( '%1$s created a new project, %2$s ', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); | |
} | |
if( $post->post_type == 'sfwd-courses' ) { | |
$activity_action = sprintf( __( '%1$s added a new workshop, %2$s ', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); | |
} | |
if( $post->post_type == 'uig_image' ) { | |
$activity_action = sprintf( __( '%1$s added a new image, %2$s ', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' ); | |
} | |
return $activity_action; | |
} | |
function bbg_record_my_custom_post_type_comments( $post_types ) { | |
$post_types[] = 'projects'; | |
return $post_types; | |
} | |
add_filter( 'bp_blogs_record_comment_post_types', 'bbg_record_my_custom_post_type_comments' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment