Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • in reply to: notification title #197622
     clyn
    Participant

    Ok thanks. At the moment this code create buddypress activity with title but still cant find activity stream and notification comment with post title…

    COPY CODE
    function monkey1980_include_post_type_title( $action, $activity ) {
    	if ( empty( $activity->id ) ) {
    		return $action;
    	}
    
    	if ( 'new_mot' != $activity->type ) {
    		return $action;
    	}
    	
    
    	preg_match_all( '/<a.*?>([^>]*)<\/a>/', $activity->action, $matches );
    
    	if ( empty( $matches[1][1] ) || 'Mot' != $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 ), $activity->action );
    }
    add_filter( 'bp_activity_custom_post_type_post_action', 'monkey1980_include_post_type_title', 10, 2 );
    in reply to: Kleo Child Theme #129088
     clyn
    Participant
    Not marked as solution
Viewing 2 posts - 1 through 2 (of 2 total)

Log in with your credentials

Forgot your details?