blogid; //get all the category ID's for the post $post_categories = wp_get_post_categories($post_id); foreach($post_categories as $c) { //get the slug for the current category $cat = get_category($c); $cat_slug = $cat->slug; //get group slug $groupr_id = groups_get_id($cat_slug); } 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 ( !in_array( $post->post_type, apply_filters( 'bp_blogs_record_post_post_types', array( '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 published a new post, %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 published a new post, %2$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), '' . $post->post_title . '' ); // Make sure there's not an existing entry for this post (prevent bumping) if ( bp_is_active( 'activity' ) ) { $existing = bp_activity_get( array( 'filter' => array( 'user_id' => (int) $post->post_author, 'action' => 'new_blog_post', 'primary_id' => $blog_id, 'secondary_id' => $post_id, ) ) ); if ( !empty( $existing['activities'] ) ) { return; } } $activity_content = $post->post_content; bp_groups_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' => $groupr_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_modified_gmt, 'hide_sitewide' => false )); } // Update the blogs last activity bp_blogs_update_blogmeta( $blog_id, 'last_activity', bp_core_current_time() ); groups_update_last_activity ($groupr_id); add_filter( 'ass_this_activity_is_important', true, $type); } 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', 'bp_groups_record_post', 10, 2 ); /** * Record the activity to the actvity stream * * @since BuddyPress (1.0) * @package BuddyPress * @subpackage BlogsActivity * @global BuddyPress $bp * @param array $args * @return boolean */ function bp_groups_record_activity( $args = '' ) { global $bp; // Bail if activity is not active if ( ! bp_is_active( 'activity' ) ) return false; $defaults = array( 'user_id' => bp_loggedin_user_id(), 'action' => '', 'content' => '', 'primary_link' => '', 'component' => 'groups', 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => bp_core_current_time(), 'hide_sitewide' => false ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); // Remove large images and replace them with just one image thumbnail if ( !empty( $content ) ) $content = bp_activity_thumbnail_content_images( $content, $primary_link ); if ( !empty( $action ) ) $action = apply_filters( 'bp_blogs_record_activity_action', $action ); if ( !empty( $content ) ) $content = apply_filters( 'bp_blogs_record_activity_content', bp_create_excerpt( $content ), $content ); // Check for an existing entry and update if one exists. $id = bp_activity_get_activity_id( array( 'user_id' => $user_id, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id ) ); return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); add_filter( 'ass_this_activity_is_important', true, $type); } ?>