Autoblog Posts not Showing in Buddypress Activity Stream

Autoblog is working fine, posting to the main blog, and attributing the posts to the correct author. The posts show fine on the main blog. However, they do not display in the buddypress activity stream of the author. Other activity, such as bbpress forum posts, does display correctly in the activity stream -- but not the blog posts. I do not have "Allow activity stream commenting on posts and comments" activated, but don't think that should prevent blog posts from showing in the stream. I've tried the "Repair member 'last activity' data" option available from the Tools menu in Network Admin, to no avail. Any other ideas?

  • Ash
    • WordPress Hacker

    Hello xbladerunner

    Please try the following code:

    add_action( 'autoblog_post_post_insert', function( $post_id, $details, $item ) {
    	if( function_exists( 'bp_activity_add' ) )
    	{
    
    		bp_activity_add( array(
                'action' => '<a href="' . get_author_posts_url( get_the_author_meta( '$post_id' ) ) . '">tota</a> wrote a new <a href="' .get_permalink( $post_id ) . '">post</a>',
                'component' => 'post',
                'type' => 'new_blog_post',
                'hide_sitewide' => false
            ) );
        }
    }, 99, 3 );

    You can use this code in your child theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

  • xbladerunner
    • Syntax Hero

    Hi Ash -- I'm trying to get the blog post activity to post in the author's activity stream, and the code you shared is only posting on the community activity stream. Further, when it posts to the community activity stream, it's stripped of the feature image and author details, here's a screen shot:
    [image pos="0"]
    Do you have any ideas?

  • Ash
    • WordPress Hacker

    Hello xbladerunner

    Would you please try the following code?

    add_action( 'autoblog_post_post_insert', function( $post_id, $details, $item ) {
    	if( function_exists( 'bp_activity_post_type_publish' ) )
    	{
    		$user_id = 10;
    		bp_activity_post_type_publish(
    			$post_id,
    			get_post( $post_id ),
    			$user_id
    		);
        }
    }, 99, 3 );

    Make sure you set the correct author ID in $user_id = 10;

    Let us know if that works. Have a nice day!

    Cheers,
    Ash

  • xbladerunner
    • Syntax Hero

    Turns out that I had my BuddyPress network settings misconfigured. I was NOT tracking site activity, because I didn't want the feed from any sites other than the main site on the network -- I didn't realize that this setting additionally deactivated tracking of activity on the main site. Once that setting was adjusted, blog activity started showing up in the BuddyPress activity stream, without any of the code provided above required. Sorry for the confusion.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.