0

I have a Custom Post Type classified I figured out how to record an activity in the BuddyPress activity stream whenever a new post of type classified is created.

What I am specifically looking to do is either modify the above code or start fresh so that whenever a post of type classified is edited a new activity is recorded.

Here is the inspiration for the original code if it helps

https://bp-tricks.com/snippets/adding-a-new-activity-stream-entry-when-a-user-changes-his-avatar/

1

Use the save_post hook. Try something like:

function jude_classified_activity_entry( $post_id, $post, $update ) {

    $slug = 'classified';

    if ( $slug != $post->post_type )
        return;

    bp_activity_add( 
      // etc
    );

}
add_action( 'save_post', 'jude_classified_activity_entry', 15, 3 );
2
  • Is there a way to check if the post was updated and not created when this triggers ? The codex is not very clear on the params for this hook. Im guessing we can use $update somehow .. but not sure. I already have it setup for a new post using the publish_post hook. – LumberHack Aug 19 '15 at 0:55
  • You can just use save_post and check status to make sure it's not a draft. – shanebp Aug 19 '15 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.