BuddyDev

Search

How can I display custom post type in buddypress activity

  • Inactive
    Level: Enlightened
    Posts: 28
    Kikismedia on #32961

    Please is there a way I can display a custom post type in buddypress or can give me a snippet that’s can display WooCommerce product in activity stream

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #32966

    Hello Adeala,

    Thank you for posting. Try the following code which enables WooCommerce product post type to be recordable.

    
    add_filter( 'bp_blogs_record_post_post_types', function ( $post_types ) {
    
    	if ( ! function_exists( 'WC' ) ) {
    		return $post_types;
    	}
    
    	if ( is_array( $post_types ) && ! in_array( 'product', $post_types ) ) {
    		$post_types[] = 'product';
    	}
    
    	return $post_types;
    } );
    
    

    Please let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Master
    Posts: 152
    Hugo Callens on #36172

    Does this work for other CPTs too?
    I created a custom post type using Toolset Types and I would like to add a message to the activity stream each time a user creates a post or comments to someone else’s post.
    I tried several solutions but with no luck so far.

    Any help much appreciated!

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #36180

    Hello Hugo,

    Thank you for asking. Try the following code for CPT

    
    
    add_filter( 'bp_blogs_record_post_post_types', function ( $post_types ) {
    
            // Replace movie with your post type.
    	$post_type = get_post_type_object( 'movie' );
    
    	if ( ! $post_type || ! $post_type->public || in_array( 'movie', $post_types ) ) {
    		return $post_types;
    	}
    
    	$post_types[] = 'movie';
    
    	return $post_types;
    } );
    

    Please do let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Master
    Posts: 152
    Hugo Callens on #36376

    Thanks Ravi.

    I added this code to my bp-custom.php and also tried functions.php. I tried with the singular name and with the slug, but no success so far. Any ideas?

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #36389

    Hello Hugo,

    We have added support for Custom Post UI campatibility directly into to the plugin. So no need to add any custom code. Please make you are using latest version of plugin. Please do let me know if it works or not.

    Regards
    Ravi

  • Participant
    Level: Master
    Posts: 152
    Hugo Callens on #36393

    Hi Ravi,

    Which plugin are you talking about? In my case it is about a cpt created by a third party plugin.
    FYI I am using the Community builder Pro theme.

    • This reply was modified 3 years, 8 months ago by Hugo Callens.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on #36401

    Hello Hugo,

    Thank you for the acknowledgement. I will check with CommunityBuilder Pro theme and let you know.

    Regards
    Ravi

  • Keymaster
    (BuddyDev Team)
    Posts: 24577
    Brajesh Singh on #36426

    Hi Ravi, Hugo,

    The activity recording has nothing to do with the theme. If it works for any theme, It will work with the Community Builder pro too.

    Please check that it works properly.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved