function media_record_post( $post_id, $post, $user_id = 0 ) { global $bp, $wpdb; $post_id = (int)$post_id; $blog_id = (int)$wpdb->blogid; if ( !$user_id ) $user_id = (int)$post->post_author; // Stop infinite loops with WordPress MU Sitewide Tags. // That plugin changed the way its settings were stored at some point. Thus the dual check. if ( !empty( $bp->site_options['sitewide_tags_blog'] ) ) { $st_options = maybe_unserialize( $bp->site_options['sitewide_tags_blog'] ); $tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0; } else { $tags_blog_id = isset( $bp->site_options['tags_blog_id'] ) ? $bp->site_options['tags_blog_id'] : 0; } if ( (int)$blog_id == $tags_blog_id && apply_filters( 'bp_blogs_block_sitewide_tags_activity', true ) ) return false; // Don't record this if it's not a post if ( $post->post_type == 'post' ) return false; $is_blog_public = apply_filters( 'bp_is_blog_public', (int)get_blog_option( $blog_id, 'blog_public' ) ); if ( 'publish' == $post->post_status && empty( $post->post_password ) ) { if ( $is_blog_public || !is_multisite() ) { // Record this in activity streams $post_permalink = get_permalink( $post_id ); if ( is_multisite() ) $activity_action = sprintf( __( '%1$s uploaded a new object, %2$s, on the site %3$s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '' . $post->post_title . '', '' . get_blog_option( $blog_id, 'blogname' ) . '' ); else $activity_action = sprintf( __( '%1$s uploaded a new object, %2$s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '' . $post->post_title . '' ); $activity_content = $post->post_content; bp_blogs_record_activity( array( 'user_id' => (int)$post->post_author, 'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, $post, $post_permalink ), 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, $post, $post_permalink ), 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), 'type' => 'new_blog_post', 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_modified_gmt )); } // Update the blogs last activity bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() ); } else { bp_blogs_remove_post( $post_id, $blog_id, $user_id ); } do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id ); } add_action( 'save_post', 'media_record_post', 10, 2 );