BuddyDev

Search

[Resolved] Having problems with showing BuddyBlog posts in activity feeds

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #300

    Hello!

    So I created a custom post type (“blog_post”) using WPMUDEV’s CustomPress plugin. Then I configured BuddyBlog to use the “blog_post” type so it would only show on user profiles. It all works great!!

    Now I’m trying to get the custom blog_post type to display in activity feeds. It does, but…the activity mention is a bit generic:
    “[Member] published a blog post 1 minute ago”

    I’d like it to also include the title of the blog post (or an excerpt is fine too, but the title is preferred), as well as a thumbnail of the featured image. WPMUDEV support was helping me for a bit in this thread, but we got stuck — and can’t figure out what the problem is.

    If we add a post from the backend, it works (the activity feed mention shows with title and image) — but if we add BuddyBlog post from the front end (which is how the site is designed to do), then it just gives us the generic version. We were hoping you might be able to tell us if there is something else that’s required for BuddyBlog for it to show up in activity feeds?

    Here’s the code that we currently have in my bp-custom.php file:


    <?php

    // Adds custom Blog Post Type to activity feed

    add_post_type_support( 'blog_post', 'buddypress-activity' );

    function customize_page_tracking_args() {
    // Check if the Activity component is active before using it.
    if ( ! bp_is_active( 'activity' ) ) {
    return;
    }

    bp_activity_set_post_type_tracking_args( 'blog_post', array(
    'bp_activity_admin_filter' => __( 'Published a new Blog Post', 'buddypress' ),
    'bp_activity_front_filter' => __( 'Blog Posts', 'buddypress' ),
    'contexts' => array( 'activity', 'member' ),
    'activity_comment' => true,
    'bp_activity_new_post' => __( '%1$s posted a new blog post', 'buddypress' ),
    'bp_activity_new_post_ms' => __( '%1$s posted a new blog post, on his profile', 'buddypress' ),
    'position' => 100,
    ) );
    }
    add_action( 'bp_init', 'customize_page_tracking_args' );

    // Adds title of custom Blog Post Type instead of excerpt

    function record_cpt_activity_content( $cpt ) {

    if ( 'new_blog_post' === $cpt['type'] ) {

    $cpt['content'] = get_the_title();
    }

    return $cpt;
    }
    add_filter('bp_after_activity_add_parse_args', 'record_cpt_activity_content');

    // Adds custom blog featured image to activity feed

    function record_cpt_activity_content_featured_image( $cpt ) {

    if ( 'new_blog_post' === $cpt['type'] ) {

    global $wpdb, $post, $bp;
    $theimg = wp_get_attachment_image_src( get_post_thumbnail_id( bp_get_activity_secondary_item_id() ) );
    $cpt['content'] .= '';
    }

    return $cpt;
    }
    add_filter('bp_after_activity_add_parse_args', 'record_cpt_activity_content_featured_image');

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #301

    Oops – the code above seem to render weirdly in a couple of places. Unfortunately I can’t seem to edit it.

    After…

    $cpt[‘content’]

    …it should read…

    = get_the_title();

  • Keymaster
    (BuddyDev Team)
    Posts: 22176
    Brajesh Singh on #309

    Hi Rojo,
    I am sorry that you are having issues with it. Please allow me to check it tonight and get back to you. I will be away for at least 10 hours, so just wanted to keep you updated. My other team mate is not familiar with this plugin much, so she can not help during that time.

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #311

    Thanks for letting me know. I look forward to you taking a look and seeing what could possibly be done. Thank you!

  • Keymaster
    (BuddyDev Team)
    Posts: 22176
    Brajesh Singh on #320

    Now, looking at it. Sorry for the delay. Got stuck in something else.

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #323

    Thanks. I look forward to what you have to say.

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #325

    Any luck? Please let me know if you need any further details.
    Thanks!!

  • Keymaster
    (BuddyDev Team)
    Posts: 22176
    Brajesh Singh on #340

    Hi Rojo,
    I am sorry I could not put much time into it. Will be doing today for sure and will get back to you.

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #347

    Thank you — it is much appreciated!!

  • Participant
    Level: Enlightened
    Posts: 30
    Rojo on #431

    Hello!

    Have you had a chance to look into this yet, by chance?

    I’m still having trouble getting the title and featured image of my BuddyBlog posts to appear in activity feeds when publishing from the front-end. (It only works when publishing from the back end — but that’s not an option for regular members). A few people have looked into this, trying to help me, but also got stuck — and each time they recommended going back to the developer for possible additional info.

    The activity feeds are a MAJOR component of my site, and it’s important that member blog posts have a way of standing out. If the blog posts are all generic and look the same, no one will pay any attention to them. Showing a thumbnail of the featured image is a must. Also…either the title (first choice) or an excerpt of the blog post content (second choice) would be nice to have as well.

    I just can’t seem to figure out why activity mentions are so generic when posting on the front-end!!

    Any help would be greatly appreciated. THANKS!

You must be logged in to reply to this topic.

This topic is: resolved