Support » Plugin: BuddyPress Group Email Subscription » Truncate / shorten bbpress posts in digests?

  • Dear @boonebgorges,

    I hope I find you well. I was wondering, is there a possibility to truncate / shorten forum topics that end up in the weekly digest? Ideally I would like to set a limit to maybe 100 characters per topic and afterwards it says “view full topic post” or something like that.

    Would also be great if the same could be done for Buddypress posts!

    Is that possible?

    Kind regards, Philip

Viewing 1 replies (of 1 total)
  • Plugin Author Boone Gorges

    (@boonebgorges)

    Yes, it’s possible, though it would take a custom plugin to do so. This is an untested skeleton, but it could point you in the right direction:

    
    add_filter(
            'ass_digest_content',
    	function( $item_content, $item, $type ) {
    		switch ( $item->type ) {
    			case 'bbp_topic_create' :
    			case 'bbp_reply_create' :
    				$excerpt = bp_create_excerpt( $item->content, 100 );
    
    				$read_more = sprintf(
    					'<a href="%s">%s</a>',
    					esc_attr( bp_activity_get_permalink( $item->id, $item ) ),
    					'View full topic post'
    				);
    
    				$item_content = $excerpt . ' ' . $read_more;
    			break;
    		}
    
    		return $item_content;
    	},
    	10,
    	3
    );
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.