Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 1 replies (of 1 total)

  • mattagland
    Participant

    @mattagland

    I’ve managed to work around this by using the bp_get_activity_content_body filter.

    However I’m sure I should be able to use bp_before_activity_add_parse_args, as the newly created custom post id exists at that point in the secondary_item_id array key…

    /* functions to pull content into activity feed from post */
    function record_cpt_activity_content( $cpt ) {
    
    	// get_post_title($cpt['secondary_item_id']) works.
    	// get_post_meta($cpt['secondary_item_id'], 'YOUR_META_KEY_HERE', true) doesn't...
    
            
    	if ('YOUR_CUSTOM_POST_TYPE' == $cpt['type']) {
    		// need to add at least a space here to the content otherwise the filter bp_get_activity_content_body doesn't seem to work...
    		$cpt['content'] = ' ';  
     	}
    
    	return $cpt;
    }
    add_filter('bp_before_activity_add_parse_args', 'record_cpt_activity_content');
    
    function filter_cpt_activity_content( $content, $activity ) {
    
    	if ( isset( $activity->secondary_item_id ) && 'YOUR_CUSTOM_POST_TYPE' == $activity->type) {
    		$current_post = $activity->secondary_item_id;
    			
    		// trim any white space added by record_cpt_activity_content()
    		$content = trim($content);
    			
    		// add in our custom content
    		$content .= get_post_meta($current_post, 'YOUR_META_KEY_HERE', true).'">'; 
    	}
    
    	return $content;
    }
    add_filter( 'bp_get_activity_content_body', 'filter_cpt_activity_content', 1, 2 );

    Obviously replace YOUR_CUSTOM_POST_TYPE and YOUR_META_KEY_HERE.

Viewing 1 replies (of 1 total)
Skip to toolbar