@mvp13585
Active 3 years ago
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Hi,
i have similar problem.
i have a custom post type “dwqa-question”i try the above code but the activity use default output.
here my code in bp-custom :
//dwqa-question function dwqa_question_activity_args() { if ( ! bp_is_active( 'activity' ) ) { return; } add_post_type_support( 'dwqa-question', 'buddypress-activity' ); bp_activity_set_post_type_tracking_args( 'dwqa-question', array( 'component_id' => 'activity', 'action_id' => 'new_dwqa_question', 'bp_activity_admin_filter' => __( 'Published a new Question', 'text-domain' ), 'bp_activity_front_filter' => __( 'Question', 'text-domain' ), 'contexts' => array( 'activity', 'member' ), 'activity_comment' => true, 'bp_activity_new_post' => __( '%1$s posted a new Question: <a href="%2$s">[Question]</a>', 'text-domain' ), 'bp_activity_new_post_ms' => __( '%1$s posted a new Question: <a href="%2$s">[Question]</a>, on the site %3$s', 'text-domain' ), 'position' => 101, ) ); } add_action( 'init', 'dwqa_question_activity_args' ); function dwqa_question_include_post_type_title( $action, $activity ) { if ( empty( $activity->id ) ) { return $action; } if ( 'new_dwqa_question' != $activity->type ) { return $action; } preg_match_all( '/<a.*?>([^>]*)<\/a>/', $action, $matches ); if ( empty( $matches[1][1] ) || '[Question]' != $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', 'dwqa_question_include_post_type_title', 10, 2 );
do you know what’s wrong with this code?
Viewing 1 replies (of 1 total)