Skip to:
Content
Pages
Categories
Search
Top
Bottom

Adding Multiple Custom Activity Feeds to the Stream


  • knownocode
    Participant

    @knownocode

    Hi, I am working with this code I found to show a CPT of fb_url_submit links. It works great but I would like to add other CPT’s to display in the same way on the Buddypress activity feeds, but with a different link of course.

    When I try it says I cannot duplicate one of the CPT activity actions, and I am not a coder, so could someone please help me figure how to add the CPT’s of “news” and “images” while also showing them in the activity stream, and able to change the link that is displayed?

    Thank you in advance!


    <?php
    function inspired_record_more_types( $types ) {
    $types[] = 'fb_url_submit';
    return $types;
    }
    add_filter( 'bp_blogs_record_post_post_types', 'inspired_record_more_types');
    ?>

    <?php
    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 == 'fb_url_submit' ) {
    if ( is_multisite() )
    $activity_action = sprintf( __( '%1$s added a new Facebook Page', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '' . $post->post_title . '', '' . get_blog_option( $blog_id, 'blogname' ) . '' );

    else
    $activity_action = sprintf( __( '%1$s added a new Facebook Page', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '' . $post->post_title . '' );

    }

    return $activity_action;
    }

Viewing 5 replies - 1 through 5 (of 5 total)

  • knownocode
    Participant

    @knownocode

    Can anyone help?


    danbp
    Moderator

    @danbp

    Read and learn from here:

    Post Types Activities


    knownocode
    Participant

    @knownocode

    Thanks Dan! A bit over my head but will definitely give it a try!


    knownocode
    Participant

    @knownocode

    I fixed this problem, much thanks! I was wondering though, is there any way to show the post-link? I am using multisite and have sub-directory sites with CPT’s and those are what I have added the functions for (normal posts system works fine).

    I am using the link for the sub-directory site for now since I don’t know how to do this, but would like to have the actual post-link itself displayed/linked in the activity feed. Is there an easy fix for this? Thanks again!


    knownocode
    Participant

    @knownocode

    Thanks again for the link and info, I have got it working but now I have run into two problems. I want the image to show and the 2 problems are the 2 feeds, as 1 is custom work, and the other I have no idea where it is.

    I simply want to show a small image of the post to show under the text in the BP activity feed, this for the one I edited the file for, can I just place this somewhere in the code shown in the link you gave??

    [ get_the_post_thumbnail( get_the_ID(), ‘image-class’ ); ]

    And for the one I am not sure about the file, I believe buddypress may be doing it on its own (am not sure) but it posts like “User-Name posted a listing, Listing-Name, on the Sub-Site-Link”. However if I do not auto-publish these feeds and have to manually approve from the backend using “quick-edit”, it works to feed the image through? Is there maybe a file location in buddypress that might do this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar