Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: Inserting activity content via plugin

@henrywright

Moderator

Right, I’m with you.

After this line in the plugin

echo 'Shared successfully to your Home Place with tags: '.$tags;

Can you add this?

do_action( 'newsbaby_after_insert_post', $post_id );

Then change my code you added to functions.php to:

function valuser_add_new_post_activity( $post_id ) {
    $post = get_post( $post_id );
    $user = get_userdata( $post->post_author );

    $args = array(
        'user_id' => $post->post_author,
        'action' => $user->user_login . ' published ' . $post->post_title,
        'component' => buddypress()->blogs->id,
        'type' => 'new_blog_post',
        'item_id' => get_current_blog_id(),
        'secondary_item_id' => $post->ID,
        'recorded_time' => bp_core_current_time(),
        'hide_sitewide' => false
    );
    bp_activity_add( $args );
}
add_action( 'newsbaby_after_insert_post', 'valuser_add_new_post_activity' );

That should do it 🙂

Skip to toolbar