Skip to:
Content
Pages
Categories
Search
Top
Bottom

Another Custom Post Type in Activity Stream


  • Cidade Sonho
    Participant

    @somdefabrica

    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)

  • danbpfr
    Participant

    @chouf1


    Cidade Sonho
    Participant

    @somdefabrica

    `// 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


    danbpfr
    Participant

    @chouf1

    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;


    Cidade Sonho
    Participant

    @somdefabrica

    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


    Cidade Sonho
    Participant

    @somdefabrica

    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

    @johnnymestizo

    Hiya,

    Does this code work?

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

    Cheers,

    Johnny


    johnnymestizo
    Participant

    @johnnymestizo

    Will this work for all CPT posts WPMS network wide?

    Cheers,

    Johnny


    Cidade Sonho
    Participant

    @somdefabrica

    This work with one cpt, i wish add another.

    this code it´s okay.

    modify “user_images” by your_custom_post


    ewebber
    Participant

    @ewebber

    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

    @johnnymestizo

    Nice!


    @ewebber
    any demo site link?


    ewebber
    Participant

    @ewebber

    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

    @ewebber

    @johnnymestizo you can see it on there now


    Good in Today
    Participant

    @goodintoday

    @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

    @ewebber

    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.


    Good in Today
    Participant

    @goodintoday

    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

    @ewebber

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


    Good in Today
    Participant

    @goodintoday

    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

    @ewebber

    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.


    Good in Today
    Participant

    @goodintoday

    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

    @ewebber

    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