Skip to:
Content
Pages
Categories
Search
Top
Bottom

Another Custom Post Type in Activity Stream

  • @somdefabrica

    Participant

    Hello BP Members, I wish add another Custom Post Type in Activity Stream, is there a way?

Viewing 20 replies - 1 through 20 (of 20 total)
  • @chouf1

    Participant

    @somdefabrica

    Participant

    `// Gravar Anuncio

    add_filter ( ‘bp_blogs_record_post_post_types’, ‘activity_publish_custom_post_types’,1,1 );
    function activity_publish_custom_post_types( $post_types ) {
    $post_types[] = ‘user_images’;
    return $post_types;
    }

    add_filter(‘bp_blogs_activity_new_post_action’, ‘record_cpt_activity_action’, 1, 3);
    function record_cpt_activity_action( $activity_action, $post, $post_permalink ) {
    global $bp;
    if( $post->post_type == ‘user_images’ ) {
    if ( is_multisite() )
    $activity_action = sprintf( __( ‘%1$s publicou um novo Anúncio: %2$s’, ‘buddypress’ ), bp_core_get_userlink( (int) $post->post_author ), ‘‘ . $post->post_title . ‘‘, ‘‘ . get_blog_option( $blog_id, ‘blogname’ ) . ‘‘ );

    else
    $activity_action = sprintf( __( ‘%1$s publicou um novo Anúncio: %2$s’, ‘buddypress’ ), bp_core_get_userlink( (int) $post->post_author ), ‘‘ . $post->post_title . ‘‘ );

    }

    return $activity_action;
    }`

    This i use to record ONE activity, but HOW to register ANOTHER

    @chouf1

    Participant

    Give this a try (not tested)
    function activity_publish_custom_post_types( $post_types ) {
    $post_types[] = ‘user_images’;
    $post_types[]. = ‘my_other_CPT’;
    return $post_types;

    @somdefabrica

    Participant

    I not try this but maybe work 🙂 thanks!

    But I wish another custom … in your example: 2 custom post type to same activity :\

    Thanks from Brazil

    http://www.cidadesonho.com/atividades Activity

    @somdefabrica

    Participant

    Hello BP team, I don´t found anything yet … anyone can help me?

    I wish register antoher custom post type in activity stream

    Thanks for all hard work BP <3

    @johnnymestizo

    Participant

    Hiya,

    Does this code work?

    I want to add ‘products’ CPT to activity stream…

    Cheers,

    Johnny

    @johnnymestizo

    Participant

    Will this work for all CPT posts WPMS network wide?

    Cheers,

    Johnny

    @somdefabrica

    Participant

    This work with one cpt, i wish add another.

    this code it´s okay.

    modify “user_images” by your_custom_post

    @ewebber

    Participant

    I just did something like this for cpt “business” and “event”, but removed mention of multisite:

    // add custom post type business to the activity stream
    
    add_filter ( 'bp_blogs_record_post_post_types', 'activity_publish_custom_post_types',1,1 );
    function activity_publish_custom_post_types( $post_types ) {
    $post_types[] = 'business';
    $post_types[] = 'event';
    return $post_types;
    }
    
    add_filter('bp_blogs_activity_new_post_action', 'record_cpt_activity_action', 1, 3);
    function record_cpt_activity_action( $activity_action, $post, $post_permalink ) {
    global $bp;
    if( $post->post_type == 'business' ) {
    
    $activity_action = sprintf( __( '%1$s created a new business listing, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '' . $post->post_title . '' );
    
    }
    
    if( $post->post_type == 'event' ) {
    
    $activity_action = sprintf( __( '%1$s created a new event, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '' . $post->post_title . '' );
    
    }
    
    return $activity_action;
    }
    

    @johnnymestizo

    Participant

    Nice!


    @ewebber
    any demo site link?

    @ewebber

    Participant

    It’s on my live site, but as there have been no events or businesses listed since I put the code up, you won’t see much right now http://www.yeahhackney.com

    The events that are currently there are not how it will show from now on.

    @ewebber

    Participant

    @johnnymestizo you can see it on there now

    @goodintoday

    Participant

    @ewebber you put this code into what? bp-custom.php? and how are you posting with the custom post types? I mean how are they implemented when a user submits a post to your activity feed?

    @ewebber

    Participant

    yes into bp-custom.php
    I’m not clear what else you are asking, when a post of the types I have specified in my array is created it creates an item in the activity table.

    @goodintoday

    Participant

    Sorry, got sidetracked… Go me! LoL

    Anyway, the second part of my question was / is in reference too exactly what you just said… You’ve stated that ‘When a post of the types I have specified in my array is created’… My question is in reference to this statement. How are your users, on the Activity Feed, selecting to POST in the specified types? Dropdown? Radio button?

    I’m curious because PHP happens on the Server Side prior to the page being sent to the user, as far as I know, so I’m not sure how your Activity Feed is, after the fact, telling BuddyPress’s Activity Feed that the user has SELECTED to Post an Event or a Business or whatever.

    @ewebber

    Participant

    Users do not create posts from the activity stream, I’m not sure that this is possible.

    @goodintoday

    Participant

    Activity Updates. You know where they can post updates. You have three, the default, the events, and business. At least according to this code.

    @ewebber

    Participant

    Your question was “How are your users, on the Activity Feed, selecting to POST in the specified types”. They cannot post from the activity stream.

    I think the confusion here is you are questioning how users can create custom post types and that’s a different topic to this thread.

    The default way would be from the admin dashboard. Other ways are possible depending on your own personal set up and what you want to do.

    @goodintoday

    Participant

    It’s okay. I looked at your site and sort of answered my question myself. You’re using Gravity Forms, that’s how you’re allowing your users to post via the custom post types. That’s all I wanted to know. Thanks for your help anyway. 🙂

    @ewebber

    Participant

    I am using Gravity forms, but that’s only for standard posts not custom post types.
    But I’ll leave you to work out the best ways to do what your site needs to do.

Viewing 20 replies - 1 through 20 (of 20 total)
  • The topic ‘Another Custom Post Type in Activity Stream’ is closed to new replies.
Skip to toolbar