Skip to:
Content
Pages
Categories
Search
Top
Bottom

Modifying blog post with custom activity type posts new item instead of updating old one


  • Daniel Koskinen
    Participant

    @daniel-koskinen

    Hi there, BuddyPress developers! I’m developing a little plugin that checks the post format (WP 3.1) and if the format is say, “image”, changes the activity type from ‘new_blog_post’ to ‘new_image_post’. My intention is to then use a custom activity stream to show a gallery of image posts. So far everything works as it should.
    However, if I update the original post, a new activity item is created instead of simply updating the existing one. I can’t figure out why this is happening, since simply changing the activity type shouldn’t effect this at all. I’m using the ‘bp_activity_type_before_save’ filter to modify the type.

    Here’s my code:

    `
    function pbpf_filter_activity( $type, $activity ) {
    // get the current post format
    $format = get_post_format( $activity->secondary_item_id );

    // return the original type if no format is set
    if ( false === $format )
    return $type;

    return ‘new_’. $format .’_post’;

    }
    add_filter(‘bp_activity_type_before_save’, ‘pbpf_filter_activity’);
    `

  • The topic ‘Modifying blog post with custom activity type posts new item instead of updating old one’ is closed to new replies.
Skip to toolbar